Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器 软件资源

软件开发小程序制作系统集成与运维空间租用硬件开发视频监控技术咨询与支持——联系电话:0311-88999002/88999003

首页 / 操作系统 / Linux / Java IO之有缓冲的文本输出

就是写入一个文件,即Output(O)。
 
  1. package com.sinosuperman.driver;  
  2.   
  3. import java.io.BufferedWriter;  
  4. import java.io.File;  
  5. import java.io.FileWriter;  
  6. import java.io.IOException;  
  7. import java.io.PrintWriter;  
  8.   
  9. public class MainBench {  
  10.     public static void main(String[] args) throws IOException {  
  11.         MyStream stream = new MyStream("temp/test.txt");  
  12.     }  
  13. }  
  14.   
  15. class MyStream {  
  16.     public MyStream(String pathName) throws IOException {  
  17.         PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(new File(pathName))));  
  18.         out.println("I"m Michael C. Zhong");  
  19.         out.println("Education Background:");  
  20.         out.println(" 2006-2011, University of Science and Technology of China.");  
  21.         out.print(" Computer Science and Technology, Bachelor Degree.");  
  22.         out.close();  
  23.     }  
  24. }