Channel of Javanio

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.