Java Basic IO Framework

Source: Internet
Author: User

A: The concept of stream design

Java abstracts the input/output into streams, the source and destination of the data, and the stream object that connects the two. Metaphor
, the data is like water, a stream is a pipe, and the water flows from one end to the other through the connection of the pipe.

When you do not use InputStream and outputstream, you must use the close () method to close the stream.

Two: Streaming inheritance architecture

Common class inheritance schemas for 1.InputStream:

Common class inheritance schemas for 2.OutputStream:

Note: FileInputStream, FileOutputStream is in bytes when reading, writing to the document

III: Stream Processing Adorner

The commonly used packager has the function of buffer bufferedinputstream, Bufferedoutputstream, with data conversion processing DataInputStream, DataOutputStream, With the ability of object serialization ObjectInputStream,

ObjectOutputStream and so on. Since these classes themselves do not change the behavior of InputStream, OutputStream, but after the InputStream to obtain data, then do some processing, or to do some processing in the output, and then by the OutputStream really output, They are therefore called adorners (Decorator).

Several commonly used stream decorator classes:

Bufferedinputstream and Bufferedoutputstream. DataInputStream and DataOutputStream. ObjectInputStream and ObjectOutputStream.

Four: Character processing classes

1.Reader and Writer Inheritance architecture

2. Character processing Adorner

InputStreamReader and OutputStreamWriter

BufferedReader and BufferedWriter

PrintWriter:

PrintWriter is very similar to PrintStream, except that it can be packaged in OutputStream,
PrintWriter can also package Writer, providing methods such as print (), println (), Format (), and so on.

Java Basic IO Framework

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.