IO流

/ 字符流 字节流
输入流 inputstream reader
输出流 outputstream writer

InputStream方法

  • int read()throws IoException //读取一个字节并以整数的形式返回(0-255),如果返回-1则已到输入流末尾。
  • int read(Byte[] buffer) throws IoException //读取一系列字节并存储到一个数组buffer,返回实际读取的字节数,如果读取前已到输入流末尾返回-1.
  • int read(Byte[] buffer,int offset,length) throws IOException //读取length个字节并存储到一个数组buffer,从length位置开始返回实际读取的字节数,如果读取前已到达输入流末尾返回-1.
  • void close() throws IoExcepion //关闭释放内存资源

OutputStream方法

  • void write(int b) throws IoException //向输出流写入一个字节数据
  • void write(Byte[] b) throws IoException //将一个字节类型的数组中的数据写入输出流
  • void write(Byte[] b, int off ,length) throws IoException //将一个字节类型的数组中从指定位置off开始的length个字节写入到输出流
  • void close() throws IoException //关闭流释放内存资源
  • void flush() throws IoExcepion //将输出流中缓冲的数据全部写入到目的地

Reader方法

  • int read() throws IoException //读取一个字符并以整数的形式返回(0-255),如果返回-1则已到输入流末尾
  • int read(char[] cbuf) throws IoException //读取一系列字符并存储到一个数组cbuf,返回实际读取的字符数,如果读取前已到达输入流末尾,则返回-1
  • int read(char[] cbuf,int offset,int length) throws IoExcption //读取length个字节并存储到一个数组cbuf,从length开始,返回实际读取的字符数,如果读取前已到达输入流的末尾,则返回-1
  • void close() throws IoException //关闭流释放内存资源

Writer方法

  • void write(int c) throws IoException //向输出流写入一个字符数据
  • void write(char[] cbuf) throws IoException //将一个字符类型的数组写入输出流
  • void write(char[] cbuf,int offset,length) throws IoException //将一个字符类型的数组从指定位置offset开始的length个字符写入到输出流
  • void write(String string) throws IoException //将一个字符串中的字符写入到输出流
  • void write(String string,int offset,length) //将一个字符串中从指定位置offset开始的length个字符写入到输出流
  • void close() throws IoException //关闭释放内存资源
  • void flush() throws IoException //将输出流中缓冲的数据全部写入到目的地
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容