package test.stream;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 字符流 Reader
 * @author Frost.Yen
 * @E-mail 871979853@qq.com
 * @date 2016年4月13日
 */
public class TestReader {
    public static void main(String[] args) {
        BufferedReader br = null;
        
        try {
            //字符流用来读取字符数据,对于输入字符流而言,最为常用的操作方法是使用BufferedReader,因为该流有个readLine()
            br = new BufferedReader(new FileReader("E:\\JAVA\\Examples\\To Learn\\src\\test\\stream\\test.txt"));
            String str = null;
            while((str = br.readLine())!=null){
                System.out.println(str);
            }
            
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            try {
                if(br!=null) br.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
    }
}

 

相关文章:

  • 2021-09-06
  • 2022-12-23
  • 2021-11-13
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-31
  • 2021-07-13
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案