JavaI/OIO development I/O is the main channel for machines to obtain or exchange information. NIO was introduced from JDK1.4 (transmitting data in blocks and adding asynchronous communication ). Added the new feature NIO.2 from JDK1.7 to add the asynchronous channel function and new file system API for the language. IO operations are divided into four groups of byte-based I/O interfaces: InputStream and OutputStream character-based I/O interfaces: Writer and Reader disk-based I/O interfaces: file-based network operation I/O interface: the first two sets of Socket are based on the data format, and the last two sets are based on the transmission mode. We are concerned about how to improve its operation efficiency, and data format and transmission mode are the most critical factors affecting efficiency. One byte-based I/O interface can be used in combination to operate data, for example: [java] OutputStreamout = new BufferedOutputStream (new ObjectOutputStream (newFileOutputStream ("fileName"); the stream will eventually be written to the disk or network (as shown in the preceding class diagram, writing to a network is actually writing files, but there is another step to process writing to the network, that is, the underlying operating system transfers data to other places rather than local disks ). Let's take a look at the InputStream abstract class code in jdk: [java] package java. io; public abstract class InputStream implements Closeable {// MAX_SKIP_BUFFER_SIZE is used to determine the maximum buffer size to // use when skipping. private static final int MAX_SKIP_BUFFER_SIZE = 2048; // It is an abstract class that requires subclass implementation. // return: int Type 0-255 (indicates the byte read) // if it is-1, the public abstract int read () throws IOException is read; // at first glance, we can see that this read uses the following read return value. // This read is the maximum read capability of byte array B. public int read (byte B []) throws IOException {return read (B, 0, B. length);} // This read is not the maximum read capability of byte array B, but can be set to off and len/return: 0 to indicate len = 0 (usually not) //-1 uses the return value of the abstract function read (). After reading it, // (int) I reads the I-byte public int read (byte B [], int off, int len) throws IOException {/** content is omitted. Check whether the abstract method of read () is called. **/} public long skip (long n) throws IOException {/** is omitted. Check **/} public int available () throws IOException {return 0;} // public void close () of the Closeable interface () throws IOException {} // use public synchronized void mark (int readlimit) together with reset () {} public synchronized void reset () throws IOException {throw new IOException ("mark/reset not supported");} public boolean markSupported () {return false ;}}