Several important IO concepts in Java

Source: Internet
Author: User

Synchronous vs. asynchronous

Blocking or blocking, polling or event driven

Netty is event-driven

Buffer and Stream

Java has both kinds of classes for input and output (I/O): Streams and readers/writers.

Streams (InputStream, outputstream and everything that extends these) is for reading and writing binary data from files, The network, or whatever other device.

Readers and writers is for reading and writing text (characters). They is a layer on top of streams, which converts binary data (bytes) to characters and back, using a character encoding.

Reading data from disk byte-by-byte is very inefficient. One-to-speed it-to-use-buffer:instead of reading one byte at a time, you read a few thousand bytes at once, a nd put them in a buffer, in memory. Then you can look at the bytes in the buffer one by one.

Channel and Stream

The difference between channel and stream is that the channel is bidirectional, and stream can only be one-way

The channel is read and written in a chunk-chunk unit, but the stream is still dependent on a byte buffer of byte

As previously mentioned, original I/O deals with data on streams, whereas NIO deals with data in blocks.

Several important IO concepts in Java

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.