Java (java io-stream brief) and io-

Source: Internet
Author: User

Java (java io-stream brief) and io-
1. stream)

The File class cannot read or write the File content.

Reading a file refers to reading the data in the file into the memory.

Writing a file refers to writing data in the memory into the file.

What is used to read and write files? File stream.

1.1 stream Concept

A series of flowing characters

1.2. Stream features

First-in-first-out transmission of information

One byte sequence

Directionality: input stream and output stream

Ii. Division by Flow Direction

Input stream: Read data-InputStream and Reader are used as base classes

Output stream: Write Data -- OutputStream and Writer are used as the base class.

There are four base classes in total.

InputStream and outputSream are byte streams.

WhereReaderAndWriterYes.

3. Data Processing Units

Byte stream: byte input stream and byte output stream

Character stream: character input stream and character output stream

Iv. Stream base class

InputStream and outputSream are byte streams. one byte is used to transmit data.

WhereReaderAndWriterIs a bytes stream: The 16-bit Unicode character is used to transmit data.

The four classes are abstract classes and cannot be instantiated. They must be implemented through the methods provided by the four abstract classes.

V. InputStream architecture 5.1. base class of byte input stream

FileInputStream: reads data from a file.

StringBufferInputStream: Rotate strings into input streams. This class has been discarded and replaced by StringBufferReader.

PipedInputStream: connects to a PipedOutputStream, which is the input stream of the pipeline.

ByteArrayInputStream: the byte array is rotated to the input stream.

FilerInputStream: it is a decoration class, also called a filter. It has the ability to expand other input streams, and it also has a subclass of implementation.

5.2 java. io. InputStream package

6. OutputStream architecture 6.1, byte output stream base class

Basically corresponds to the InputStream above

6.2 java. io. OutputStream package

VII. Reader stream 7.1, Architecture

7.2 common methods

8. Writer stream 8.1, Architecture

8.2 common methods

9. Steps for using a stream

Open stream-use stream-close stream

Related Article

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.