1(3)IO流------字符流

时间:2023-12-14 17:00:44

一.分类

  • 字节流(不适用于文本)
  1. InputStream
  2. OutputStream
  • 字符流
  1. Reader
  2. Writer

二.字符流

  按照字符为单位,英文1-1,中文看是UTF-8编码还是GBK编码

  • 字符输出流(Write)

  • 字符输入流(Reader)
  • 缓冲字符流BufferedReader:方法更多
  • 转换流:InputStreamReader:将字节流转化成字符流
//1.将字节流穿环卫字符流
InputStreamReader isr=new InputStreamReader(new BufferedInputStream(new FileInputStream("str/*.txt"))); //2.读取字符流
BufferedReader br = new BufferedReader(isr);
System.out.println(br.readLine());

1(3)IO流------字符流