InputStreamReader 和 OutputStreamWriter类用法简介,及演示.docxVIP

  • 5
  • 0
  • 约1.57万字
  • 约 9页
  • 2017-11-17 发布于河南
  • 举报

InputStreamReader 和 OutputStreamWriter类用法简介,及演示.docx

InputStreamReader 和 OutputStreamWriter类用法简介,及演示

InputStreamReader和OutputStreamWriter类用法简介。一、InputStreamReader类InputStreamReader将字节流转换为字符流。是字节流通向字符流的桥梁。如果不指定字符集编码,该解码过程将使用平台默认的字符编码,如:GBK。构造方法:InputStreamReaderisr = new InputStreamReader(InputStream in);//构造一个默认编码集的InputStreamReader类InputStreamReaderisr = new InputStreamReader(InputStreamin,StringcharsetName);//构造一个指定编码集的InputStreamReader类。参数 in对象通过InputStream in = System.in;获得。//读取键盘上的数据。????????????????????????????????或者? ? InputStream in = new FileInputStream(String fileName);//读取文件中的数据。可以看出FileInputStream为InputStream的子类。主要方法:int read();//读取单个字符。????????????????? int read(char []cbuf);//将读

文档评论(0)

1亿VIP精品文档

相关文档