java中讲讲PrintWriter的用法,举例?
2024-09-07 19:44:41
[学习笔记]
1.2 PrintWriter的用法
PrintWriter和PrintStream类似,只不过PrintStream是针对字节流的,而PrintWriter是针对字符流的。
例:1.2.1
import java.io.*;
public class TestMark_to_win {
public static void main(String args[]) throws Exception {
String s1 = "我们" + "\n";
String s2 = "你们" + "\n";
PrintWriter p = new PrintWriter("c:/out.txt");
p.println("output" + s1);
p.println("output" + s2);
/*without using the following statement, the file name can be write out, but the content of the file is empty. */
p.close();
}
}
文章转载自原文:https://blog.csdn.net/mark_to_win/article/details/71023774
最新文章
- Windows进程崩溃问题定位方法
- java多线程-线程通信
- Linux 下安装pip
- 传智播客JavaWeb day03
- 接口自动化之Postman+Newman
- 启动图实现:UIScrollView+UIPageControl简单实现
- Call to undefined function bcscale()
- oracle学习 六 删除表空间,数据文件的语句以及导入导出dmp文件的方法(持续更新中)
- Server Error The server encountered an error and could not complete your request. 新建站点模版失败
- 【POJ2406】 Power Strings (KMP)
- 【原创】javascript——事件思维导图
- SpringNote01.基于SpringMVC-Hibernate的Blog系统
- ThinkPhp知识大全(非常详细)
- js实现省市区三级联动
- 利用Fiddler修改请求信息通过Web API执行操作(Action)实例
- JS中的函数和BOM
- [原创]Xilinx Vivado 2017.4/2018.3/2016.4/2015.4/ISE14.7下载及其安装
- hadoop2.6.0高可靠及yarn 高可靠搭建
- js点滴
- [转]wxParse-微信小程序富文本解析组件