Functions and features of common stream in Java. Io

Source: Internet
Author: User
Tags object serialization

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.