Java (java io-stream brief) and io-
1. stream)
The File class cannot read or write the File content.
Reading a file refers to reading the data in the file into the memory.
Writing a file refers to writing data in the memory into the file.
What is used to read and write files? File stream.
1.1 stream Concept
A series of flowing characters
1.2. Stream features
First-in-first-out transmission of information
One byte sequence
Directionality: input stream and output stream
Ii. Division by Flow Direction
Input stream: Read data-InputStream and Reader are used as base classes
Output stream: Write Data -- OutputStream and Writer are used as the base class.
There are four base classes in total.
InputStream and outputSream are byte streams.
WhereReaderAndWriterYes.
3. Data Processing Units
Byte stream: byte input stream and byte output stream
Character stream: character input stream and character output stream
Iv. Stream base class
InputStream and outputSream are byte streams. one byte is used to transmit data.
WhereReaderAndWriterIs a bytes stream: The 16-bit Unicode character is used to transmit data.
The four classes are abstract classes and cannot be instantiated. They must be implemented through the methods provided by the four abstract classes.
V. InputStream architecture 5.1. base class of byte input stream
FileInputStream: reads data from a file.
StringBufferInputStream: Rotate strings into input streams. This class has been discarded and replaced by StringBufferReader.
PipedInputStream: connects to a PipedOutputStream, which is the input stream of the pipeline.
ByteArrayInputStream: the byte array is rotated to the input stream.
FilerInputStream: it is a decoration class, also called a filter. It has the ability to expand other input streams, and it also has a subclass of implementation.
5.2 java. io. InputStream package
6. OutputStream architecture 6.1, byte output stream base class
Basically corresponds to the InputStream above
6.2 java. io. OutputStream package
VII. Reader stream 7.1, Architecture
7.2 common methods
8. Writer stream 8.1, Architecture
8.2 common methods
9. Steps for using a stream
Open stream-use stream-close stream