1.字节流 InputStream读取 OutputStream写数据
字符流 Reader 读取 Writer写数据
InputStream 的int read() 读一个字节,以整数返回 ,如果返回-1说明已经到末尾了
的Int read(byte[] buffer)throws IOException 读取的信息放到buffer中,返回实际读取的字节数
int read(byte[] buffer,int offset,int length)从offset开始,把之后的length个数据读取数据
close();
OutputStream 的write(int b)throws IOException 向输入流写一个字节数据
write(byte[] b) throes IOException 向输入流写一个字节数组
write(byte[] b,int off,int len)throws IOException 把字节数组从指定位置off写入len个的字节
close()throws IOException
flush()throws IOException 良好的编程习惯,应该先写flush再写close
flush()把流中的数据写入后才调用close关闭
2.BufferedInputStream bis=new BufferedInputStream (InputStream pis);带有缓冲区的
相当于管道上面再套一个管道
bis》readLine()读取一行 没有数据返回NULL
3.在对文件进行写入操作,管道还没关闭,就进行读取会有问题。
本文详细介绍了Java中的字节流InputStream和OutputStream,包括它们的基本使用方法如read()和write(),以及如何进行缓冲操作。强调了在使用BufferedInputStream时,如何读取一行以及在文件操作中正确关闭管道的重要性。
311

被折叠的 条评论
为什么被折叠?



