Concept
The shorthand for io,input and output, that is, the input outputs, so the IO stream is the output stream of input. The IO stream is equivalent to a data pipeline that is used primarily to
Place data transfer between the devices.
principle
The input and output are relative to the program itself. reading data from a file output to a program is an input stream, such as querying a database for a
user information. saves data from the program to a file as an output stream, such as adding a user information to the database.
example diagram of IO flow working principle
category
Multiple stream types are defined in java.io to implement input/output functions, which are categorized from different angles as follows:
In the same direction as the data flow: input and output streams
Varies by processing data units: byte stream and character stream
Depending on the implementation function type: node flow and processing flow
Note :
Byte stream is the most basic, it's all the InputStream and OutputStream subclasses are, mainly used in processing binary data, it is by byte
come here Management. But in fact, a lot of data are text, so there is the concept of character stream, it is the virtual machine encode to deal with, that is, to carry out the word
character set of conversions.
What is the main difference between a byte stream and a character stream from the above paragraph?
1) The byte stream does not use the buffer (memory) in the operation, and directly operates on the file itself. While the character stream uses a buffer during operation,
The Flushing Zone re-operates the file.
2) The real storage and transfer of data is in bytes, all the files on the hard disk (pictures, sounds, videos, etc.) are stored in bytes
In, the characters are only present in memory. So, the scope of the byte stream is wider
Where the input and output streams and byte stream streams are easily understood according to their definitions. A brief introduction to the next node flow and processing flow. In the next article will be done in detail
Introduced.
IO Stream Classification Integration Map
IO Stream Classification Integration Map (1)
IO Stream Classification Integration Map (2)
Summary
IO streams are used to transfer data between devices. In combination with the example of life, one pipe is inserted into a bucket and the other end is inserted in the sink. When I
when they need to store water in the pool, they need pour a bucket of water into the sink through the middle water pipe. When water is needed, it is also necessary to pass the
Water from the sink to the bucket.
The equivalence is divided into our IO stream:
Water pipe------------------Flow
Water flow------------------Data flow
Pool-------------------File
Bucket-------------------Program
Is it easier to understand than to make the abstract concrete?
Java Collection--io Flow grooming (i)