table of Contents
IO in a basic usage of each stream
Reference: the Java IO consolidation in
Two IO system
Reference: After reading this, Java IO is not difficult from
Triple buffering stream
Reference: Java IO-- Detailed stream buffer
Feature
Buffered stream file stream is 处理
a streaming, which itself 并不具备 IO
functions, but on another stream 加上缓冲
to improve the efficiency, when the target file or other frequent read and write operations, or inefficient, performance difference. At this time the buffer flow can be used more efficiently read and write information. Because the first buffered stream cached data, and writing or reading out together. Therefore, the buffer flow is still very important, remember to add the buffer flow to enhance performance when operating in IO
Unbuffered operation, 每读一个字节
will write a byte, as it involves the disk IO操作
to be compared with the memory operation 慢
a lot, so unbuffered stream 效率很低
. Buffered stream can be a lot of bytes read, but not write to the disk just 先放到内存
inside. And so lobbied for the buffer size when 一次性写入
disk, in this way can 减少磁盘操作
the number, the speed will improve a lot!
Precisely because they simultaneously achieve a buffering function, it is to be noted that in use BufferedOutputStream写完数据
, the call to flush()
the method, or close()方法(说明close前会调用flush)
, forced to write the data in the buffer. Otherwise you might not be able to write data. Similarly BufferedReader and also BufferedWriter
two classes