带有缓冲的函数,通常是为了提高效率
如BufferedOutputStream,缺省可能会申请一定大小的buf(如512)
当调用函数write时并不是马上输出到OutputStream,而是先存在buf中,等到一定长度都一起输出。系统内部的缓冲你指得是什么?
如BufferedOutputStream,缺省可能会申请一定大小的buf(如512)
当调用函数write时并不是马上输出到OutputStream,而是先存在buf中,等到一定长度都一起输出。系统内部的缓冲你指得是什么?
把输入流转换为输出流;
或者把输出流转换为输入流。
extends FilterInputStream
A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the and reset methods. When the BufferedInputStream is created, an internal buffer array is created. As bytes from the stream are read or skipped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time. The operation remembers a point in the input stream and the reset operation causes all the bytes read since the most recent operation to be reread before new bytes are taken from the contained input stream. public class BufferedOutputStream
extends FilterOutputStream
The class implements a buffered output stream. By setting up such an output stream, an application can write bytes to the underlying output stream without necessarily causing a call to the underlying system for each byte written.
另外BufferInputStream和BufferOutputStream在Java中还有一个用途:
把输入流转换为输出流;
或者把输出流转换为输入流。————————————————————————————————具体是怎么转换的啊?
PipedInputStream pis = new PipedInputStream(pos);
BufferedReader br = new BufferedReader(new InputStreamReader(pis));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(pos));bw.write("I'm artu");
bw.close();System.out.println(br.readLine());
br.close();