打印流:
该流提供了打印方法,可以将各种数据类型的数据都原样打印。
分为:PrintStream(字节打印流) PrintWriter(字符打印流)
PrintStream
构造函数可以接收的参数类型:
1. File对象。File
2. 字符串路径。String
3. 字节输出流。OutputStream
PrintWriter
构造函数可以接收的参数类型:
1. File对象。File
2. 字符串路径。String
3. 字节输出流。OutputStream
4. 字符输出流。Writer
BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));// 获取命令行获取的数据
PrintWriter pw = new PrintWriter(new FileWriter("D:\\a.txt"), true);
String line = null;
while ((line = bReader.readLine()) != null)
{
if ("over".equals(line))
{
return;
}
pw.println(line.toUpperCase());
}
pw.close();
bReader.close();