Java IO之有缓冲的文本输入


输入,就是Input(I)。

 
  1. package com.sinosuperman.driver;  
  2.   
  3. import java.io.BufferedReader;  
  4. import java.io.File;  
  5. import java.io.FileReader;  
  6. import java.io.IOException;  
  7.   
  8. public class MainBench {  
  9.     public static void main(String[] args) throws IOException {  
  10.         MyStream stream = new MyStream("temp/test.txt");  
  11.     }  
  12. }  
  13.   
  14. class MyStream {  
  15.     public MyStream(String pathName) throws IOException {  
  16.         BufferedReader br = new BufferedReader(new FileReader(new File(pathName)));  
  17.         String line = br.readLine();  
  18.         while (line != null) {  
  19.             System.out.println(line);  
  20.             line = br.readLine();  
  21.         }  
  22.         br.close();  
  23.     }  
  24. }  

相关内容