The channel is essentially a tunnel used to connect data outside the JVM to the JVM, such as files from the hard disk, packets from the network. Data outside the JVM is transmitted via channel channels, and if the channel is likened to a channel, then as the carrier of the data is the Bytebuffer,buffer metaphor is the container, specially used for transmitting the data of the container;
The acquisition of the channel is obtained by means of the file object Randomaccessfile.getchannel () and then by the read () and the Write () method to write to and read through buffer.
The flip method of buffer is to prepare for drain (reading information). The channel has several common methods: Read, write, create (channel), and close.
The Channel family has a major class: Filechannel,socketchannel and Pipe.
The FileChannel has a force method that writes data from the cache back to the hard disk, because the modern operating system is in performance, and many times it caches the modification of the data, forcing the method to write the in-memory changes back to the hard disk. The second point of FileChannel is lock.
Channel of Javanio