打印流:
該流提供了打印方法厦画,可以將各種數(shù)據(jù)類型的數(shù)據(jù)都原樣打印嘱能。
字節(jié)打印流:
PrintStream
構(gòu)造函數(shù)可以接收的參數(shù)類型:
1,file對(duì)象期吓,F(xiàn)ile
2早歇,字符串路徑。String
3讨勤,字節(jié)輸出流箭跳。OutputStream
字符打印流:
PrintWriter
構(gòu)造函數(shù)可以接收的參數(shù)類型:
1,file對(duì)象潭千,F(xiàn)ile
2谱姓,字符串路徑。String
3刨晴,字節(jié)輸出流屉来。OutputStream
4,字符輸出流狈癞。Writer
import java.io.*;
class PrintStreamDemo
{
public static void main(String[] args) throws IOException
{
BufferedReader bufr =
new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new FileWriter("a.txt"),true);
String line = null;
while((line=bufr.readLine())!=null)
{
if("over".equals(line))
break;
out.println(line.toUpperCase());
//out.flush();
}
out.close();
bufr.close();
}
}