想问一个java缓冲区的问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 11:05:22
FileInputStream f1 = new FileInputStream("1.txt");
BufferedInputStream buf = new BufferedInputStream(f1);

我想知道在执行这两个语句结束后,BufferedInputStream 所带的缓冲区里面是不是就已经有1.txt文件中的数据了,接下来用buf.read()来读取数据时是不是从这个缓冲区读取数据啊

主要就是硬盘文件到BufferedInputStream 所带的缓冲区直接的连接有点问题

A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the mark 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 mark operation remembers a point in the input stream and the reset operation causes all the bytes read since the most recent mark operation to be reread before new bytes are taken from the contained input stream.