Functions and features of common stream in java. io
In the first week of the school year, we mainly talked about java stream file operations, basic concepts of data stream, java standard data stream input/output, byte stream, file operation, and volume stream. Object serialization. Among them, the input/output of java standard data streams is important.
Let's take a look at the features and features of the stream commonly used in java. io:
Data streams are mainly InputSream (input stream) and OutputSream (output stream. The input stream can only be read and not written, and the output stream can only be written and cannot be read.
System. in is a standard input. The Byte input stream class is an InputStream object. To achieve standard input, you can use the read () method to obtain the accepted data from the keyboard.
System. out is a standard output that prints a stream-like PrintStream object. The two methods are Print () and Println (). These two methods support any basic type of JAVA parameter.
System. err is a standard error output.
Byte streams include inputstream and outputstream. These two classes are input/output-oriented superclasses, including multiple methods, reads data, writes data, marks locations, obtains data volumes, and closes data streams.
Inputstream includes many subclasses {
Fileinputstream is a file input stream used to access local files sequentially. It inherits multiple methods from the super-class inputstream, but does not support the mark () and reset () methods. Use the read () method to read the first byte.
Pipdeinputstream is the input stream of the pipeline. It accesses local files in a specific path.
Filerinputstream filters access to the input stream, including printinputstream (formatted input stream), bufferedinputstream (buffered input stream), and datainputstream (data input stream );
Objectinputstream is the object input stream for accessing local files of objects.
Bytearrayinputstream is a byte input array stream that accesses files in bytes.
}
Outputstream includes many subclasses {
Fileoutputstream is the output stream of a file. It inherits multiple methods from the input data outputstream,
Use writer () to write data into similar files.
Pipdeoutstream is the output stream of the pipeline. It writes files in a specific path.
Fileroutstream is the output stream for filtering data.
Bufferedoutputstream (buffer output stream), dataoutputstream (data output stream) printoutputstream (format output stream );
Objectoutputstream is the local file written to the object by the object output stream.
Bytearrayoutputstream writes the byte output array stream to the file.
}
Randomaccess is a random access to files. It has two features: Reading, writing, and reading and writing at random. It is more convenient than byte stream.
The character stream includes reader (character input stream) and writer (character output stream ). The method in the merge stream is similar to that in the byte stream.