10.1.1 concept of stream
1). input and output streams
Buffered stream)
10.1.2 input/output stream class library
Data processing can be divided into two types: byte stream and character stream. byte stream is also called binary byte stream) or bit stream (BITS steam ).
Java. Lang. Object->
Inputstream \ outputstream \ reader \ writer \ file \ randomaccessfile
Inputstream->
Fileinputstream \ pipedinputstream \ filterinputstream \ sequenceinputstream \... \ stringbufferinputstream
Outputstream->
Fileoutputstream \ pipedoutputstream \... \ filteroutputstream
Reader->
Pipedreader \ bufferedreader \ filterreader \ inputstreamreader \... \ stringreader
Writer->
Pipedwriter \ bufferedwriter \ filterwriter \ outputstreamwriter \... \ stringwriter
-> Filterinputstream->
Bufferedinputstream \ linenumberinputstream \ pushbackinputstream \ datainputstream
-> Filteroutputstream->
Bufferedoutputstream \ dataoutputstream \ printstream
-> Bufferedreader->
Linenumberreader
-> Inputstreamreader->
Filereader
-> Outputstreamwriter->
Filewriter
Inputstream \ outputstream \ reader and writer are abstract classes for input and output of data streams, file is a robust class for managing disk files and directories, and randomaccessfile is a stable class for instant access, it is used to perform instant read/write operations on disk files.
10.2 use inputstream and outputstream stream
Basic Input and Output streams
Common inputstream Methods
Public int read () reads a byte (8 bit) from the current position in the input stream, Supplements 8 high bytes that are all 0 to form a 16-bit int (0 ~ 255). If no data exists in the current position of the input stream,-1 is returned.
Public int read (byte B []) reads multiple bytes from the current position in the input stream and stores them in array B []. The number of bytes read is also returned.
Public int read (byte B [], int off, int Len) reads len bytes continuously from the current position in the input stream, it is stored at the off + 1 element position of array B [], and the number of bytes read is returned.
Public int available () returns the number of bytes that can be read in the input stream.
Public long SKIP (long n) causes the position pointer to skip n Bytes from the current position
Public void mark () makes a mark at the current position
Public void reset () returns the position pointer to the marked position.
Public void close () closes the connection between the input stream and peripherals and releases the system resources occupied.
Common Methods of the outputstream class
Public void write (int B) writes the low byte of parameter B to the output stream
Public void write (byte B []) writes all the bytes in the byte array B [] to the input stream in order
Public void write (byte B [], int off, int Len) Writes len data starting from the off + 1 element in the byte array B [] to the output stream in sequence.
Public void flush () Forcibly clears the buffer and writes data to the peripherals.
Public void close () closes the connection between the output stream and peripherals and releases the system resources occupied.
Flush (); Description: writes data in the buffer zone to peripherals, forcibly clears the buffer zone and performs peripheral write operations.