java IO data

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/m0_38060977/article/details/102754425

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 并不具备 IOfunctions, 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 BufferedWritertwo classes

Guess you like

Origin blog.csdn.net/m0_38060977/article/details/102754425