黑馬程序員-學習日誌-打印流

---------------------- ASP.Net+Android+IOS開發.Net培訓、期待與您交流! ----------------------


打印流:

該流提供了打印方法,可以將各種數據類型的數據都原樣打印。


字節打印流:
PrintStream
構造函數可以接收的參數類型:
1,file對象。File
2,字符串路徑。String
3,字節輸出流。OutputStream
4,字符輸出流,Writer


字符打印流:

PrintWriter


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


	}
}


---------------------- ASP.Net+Android+IOS開發.Net培訓、期待與您交流! ----------------------詳細請查看:http://edu.csdn.net

發佈了29 篇原創文章 · 獲贊 0 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章