Java核心類庫-IO-列印流(PrintStream/PrintWriter)

來源:互聯網
上載者:User

標籤:列印   print   for   puts   資料類型   color   write   簡單   object   

列印流,列印資料的,列印流只能是輸出資料流:

PrintStream:位元組列印流。

PrintWriter:字元列印流。

對於PrintWriter來說,當啟用欄位重新整理之後

PrintWriter ps = new PrintWriter(new FileOutputStream(new File("out")),true);

調用println或者printf或者format方法,便會立馬重新整理操作

如果沒有開啟自動重新整理,則需要手動重新整理或者當緩衝區滿的時候,再自動重新整理。

使用列印流作為輸出資料流,此時的輸出操作會特別簡單,因為在列印流中提供了:

  print方法:列印不換行

  println方法:列印再換行

  println和println方法都可以支援列印/輸出各種資料類型,void println(Object x)即可。

Java核心類庫-IO-列印流(PrintStream/PrintWriter)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.