In the program, all the data are transmitted and saved in the form of stream, and the program reads the data through the input stream; When the program needs to save some data for a long time, use the output stream to complete.
Data transmission between local devices and different devices, such as local file copy, upload file and download file, etc.
1. All operations on data are carried out by Java through streams
2. The input and output of the program are saved in the form of stream, and all the files saved in the stream are byte files.
3. IO stream can achieve data persistence, but IO stream is essentially used to deal with file system and data transmission between different devices.
There are two different ways of classification
1. Input stream: read data from outside (keyboard, network, file, etc.) to memory
2. Output stream: used to write the data in the program to the outside world (display, file…)
1. Byte stream: generally for binary files [video, audio, picture]
2. Character stream: generally for text files [XML, JSON, HTML, TXT, MD…]
1. Data source: where does the data come from（ Memory can be used as a destination or a transfer station)
2. Destination: where does the data go（ Memory can be used as a destination or a transfer station)
3. Means of transportation:
a. Choose the type of convection, input stream or output stream, or both
b. Select the most suitable flow in io flow frame according to the determined flow direction
Difference between byte stream and character stream:
1. Different reading and writing units: byte stream is in byte (8bit) unit, character stream is in character unit, according to the code table mapping characters, it may read more than one byte at a time.
2. Different processing objects: byte stream can process all types of data (such as pictures, avi, etc.), while character stream can only process character type data. For example: document, JSON, HTML, CSS, JS, XML
Note: as long as you are dealing with plain text data, you should give priority to the use of character stream. In addition, you should use byte stream
This work adoptsCC agreementReprint must indicate the author and the link of this article