//字節流--->字符流
1.
public class TestIO { public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream("c:/abc.txt");// 字節流 InputStreamReader isr = new InputStreamReader(fis);// 字符流 BufferedReader br = new BufferedReader(isr);// 緩沖流 String str = null; if ((str = br.readLine()) != null) { System.out.println(str); } br.close(); isr.close(); fis.close(); } }
2.
public class TestIO { public static void main(String[] args) throws IOException { FileReader fr = new FileReader("c:/abc.txt"); BufferedReader br = new BufferedReader(fr);// 緩沖流 String str = null; if ((str = br.readLine()) != null) { System.out.println(str); } fr.close(); br.close(); } }