Java Basic knowledge Summary IO stream

Source: Internet
Author: User

Understanding the IO stream of Java

Stream concept: A bridge between program and data sources

Classification of Streams

In the direction of the stream (from the memory point where the program resides):

    • Input stream: Reads the external input into the current program.
    • Output stream: Outputs data from the current program's memory to an external

Data is divided by stream:

    • BYTE stream: It deals with data units that are bytes (8bit), adaptable and powerful.
    • Character stream: The data unit that it handles is characters. In general, it mainly handles text files, which are more convenient than byte streams when working with text files.

The difference between a byte stream and a character stream:

Read-write units are different: byte stream in bytes (8bit), character stream in characters, according to the Code table mapping characters, one can read multiple bytes at a time.

The processing object is different: The byte stream can handle all types of data (slices, AVI, etc.), while the character stream can only handle data of the type of characters.

Conclusion: As long as you are working with plain text data, you will prefer to use character streams. In addition, byte streams are used.

To divide by the role of a stream:

    • Node Flow: Associate directly with the physical node of an IO (file on disk, network).
    • Wrapper flow (processing flow): A node-based flow of the resulting stream after wrapping. All inherit the base class such as filterxxx.
IO system

The basic architecture of Java Legacy IO:

byte input stream byte output stream character input stream character output stream

Inputsteam OutputStream Reader Writer

Access file Filexxx

Accessing the array bytearrayxxx chararrayxxx

Access Pipeline Pipedxxx

Access String stringxxx

Filter Flow Fileterinputstream Fileteroutputstream Fileterreader filterwriter

Buffered Stream bufferedxxx

Print Flow PrintStream PrintWriter

Convert Stream InputStreamReader OutputStreamWriter

Special Flow DataInputStream DataOutputStream

Object Flow ObjectInputStream ObjectOutputStream

Java Basic knowledge Summary IO 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.