//字节流--->字符流
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();

 }

}

 

相关文章:

  • 2022-12-23
  • 2021-10-14
  • 2021-07-22
  • 2021-12-01
  • 2021-06-22
  • 2022-12-23
  • 2021-10-01
  • 2022-01-16
猜你喜欢
  • 2021-09-08
  • 2021-12-02
  • 2022-02-03
  • 2021-10-02
  • 2021-09-24
  • 2022-01-13
  • 2022-03-07
相关资源
相似解决方案