Java programming idea--java IO system

Source: Internet
Author: User

First, what is IO

IO is essentially a single byte of movement. The flow can be said to be the carrier and way of byte movement, it keeps moving the data to the target. All we have to do is read the data from the stream in the direction of the stream or write the data to the stream.


Second, the Java support IO operation of the library class

1, according to the data types are divided into two categories:

(1) Byte type: InputStream and OutputStream

(2) Character type: writer and reader

2, according to the direction of the flow of data, mainly divided into two categories:

(1) disk operation-based IO interface: File

(2) network-based IO interface: Socket

description of Io interface for byte stream and character stream

The byte stream contains the input stream InputStream and the output stream outputstream. The character stream contains the input stream reader,

InputStream related class diagrams such as the following. Just a list of sub-classes:


InputStream provides some read methods for subclass inheritance. Used to read bytes.

OutputStream related class diagrams such as the following:


OutputStream provides some write methods for subclass inheritance, which are used to write bytes.

Reader related class diagrams such as the following:


Reader provides some read methods for inheriting from subclasses. Used to read characters.

Writer related class diagrams such as the following:


Writer provides some write methods for subclass inheritance, which are used to write characters.

Each character stream subclass almost always has a corresponding byte-stream subclass, both functions. The difference is simply whether the operation is a byte or a character.

For example, CharArrayReader and Bytearrayinputstream, both of which create an array buffer in memory as an input stream, the difference is simply that the former array is used to hold characters. Reads one character at a time from the array, while the latter is for bytes.

Bytearrayinputstream, CharArrayReader Provides a buffer operation function for multi-threaded communication. Often used to read fixed-length packets in the network
Bytearrayoutputstream, Chararraywriter Provides a buffer operation function for multi-threaded communication. Often used to receive a sufficient length of data after a write-once
FileInputStream, FileReader Write file to memory as input stream, implement read operation to file
FileOutputStream, FileWriter Writes the in-memory data as an output stream to a file. Implementing write operations on files
StringReader Reads the contents of a string as an input stream
StringWriter Writes data to a string
Sequenceinputstream Merging data from multiple input streams into one data stream
PipedInputStream, Pipedreader, PipedOutputStream, PipedWriter Pipe flow. Mainly used for data transfer between 2 threads
ObjectInputStream Reads the object data as an input stream, and member variables of the transient and static types in the object are not read or written
ObjectOutputStream Writing data to an object
FilterInputStream, Filteroutputstream, FilterReader, Filterwriter Filtering the flow Changyuan and the target is the other input and output stream, we can see there are a lot of sub-classes. For each practical purpose, we will not introduce

Java programming idea--java IO system

Related Article

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.