- FileReader 字符输入流
@Test public void test1(){ File file = new File("hello.txt"); FileReader fr = null; try { fr = new FileReader(file); //返回读取的内容 int data; while ((data = fr.read()) != -1){ System.out.print((char)data); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { if (fr != null){ try { fr.close(); } catch (IOException e) { e.printStackTrace(); } } } }