当前位置: 移动技术网 > IT编程>数据库>其他数据库 > java中讲讲PrintWriter的用法,举例?

java中讲讲PrintWriter的用法,举例?

2019年08月21日  | 移动技术网IT编程  | 我要评论
[学习笔记] 1.2 PrintWriter的用法 PrintWriter和PrintStream类似,只不过PrintStream是针对字节流的,而PrintWriter是针对字符流的。 例:1.2.1import java.io.*;public class TestMark_to_win { ...

[学习笔记]

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();
}
}

文章转载自原文:

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网