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