Java Starts from scratch 64 (Java io-stream brief)

Source: Internet
Author: User

First, stream concept (stream)

The file class does not read and write the contents of the files.

Reading a file means: Reading the data in the file into memory

Writing a file means: Write the data in memory into a file.

What do you read and write files from? File stream.

1.1. Flow Concept

A series of flowing characters

1.2, the characteristics of the flow

Advanced first-out way to pass information

A sequence of bytes

Directionality: input stream, output stream

Second, according to the flow of the division

Input stream: Read data--inputstream and reader as base class

Output stream: Write Data--outputstream and writer as base class

Altogether four 4 base classes.

Where InputStream and Outputsream are byte streams

where Reader and Writer are character streams

Third, according to the Processing Data Unit Division

Byte stream: bytes input stream, byte output stream

Characters stream: Character input stream, character output stream

Iv. base class of flow

Where InputStream and Outputsream are byte streams: 1 bytes for transmitting data

where Reader and Writer are character streams: 16-bit Unicode characters for transmitting data

4 classes are abstract classes can not be instantiated, need to pass 4 abstract classes provided by the method to implement

V. InputStream Architecture 5.1, byte input stream base class

FileInputStream: Reading data from a file

StringBufferInputStream: Rotate the string into the input stream, this class is obsolete and replaced by Stringbufferreader

PipedInputStream: Connecting a PipedOutputStream It is a pipeline to the inflow

Bytearrayinputstream: The byte array is rotated as an input stream.

Filerinputstream: is a decorative class, also known as a filter, it has the ability to extend the other input stream, it also has the implementation of the sub-class

5.2. Java.io.InputStream Bag

Vi. outputstream architecture 6.1, byte output stream base class

Basically corresponds to the inputstream above

6.2. Java.io.OutputStream Bag

Vii. Reader Flow 7.1, architecture

7.2. Common methods

Eight, writer Stream 8.1, architecture

8.2. Common methods

Ix. steps to use a flow

Open stream-use stream-close stream

Java Starts from scratch 64 (Java io-stream brief)

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.