1. NIO uses a way closer to the operating system to execute IO: Channels and buffers, as the name implies, data source data is transmitted by the buffer through the channel. 2. After JDK5, the raw IO system was optimized for NIO at the bottom, which can be found through Sun's published source code, but NIO is more systematic than IO. 3. In a little study of IO source code and some sun source code, I think the performance bottleneck of IO system is mainly due to the original IO architecture factors. The original IO system uses adapter mode, which seems like a good idea at the beginning of the JDK development, but as the adapter is nested more and more, the use of IO is annoying and can affect performance, because the dynamic implementation is definitely going to degrade performance. 4. In order to be able to verify my ideas as accurately as possible, the code in the IO section is also displayed with buffers for reading and writing. 5. Local test: 50M file: Io time 1031ms,nio time consuming 640ms;500m file: Io time 18900ms,nio time consuming 13500ms. Their time difference does not vary drastically due to file size changes, which means that both NIO and IO should be similar in the underlying processing stream, resulting in IO performance constraints on the schema of its original adapter model. Trunk Part code: 1.IO System 2.NIO System
Java vs. io and NiO file read/write performance testing