Preliminary discussion on Java I/O working mechanism

Source: Internet
Author: User

From a book: Deep inside Java Web technology

Basic architecture of the 1.Java I/O class Library

Java I/O operations class in the package, about nearly 80 classes, probably divided into the following 4 groups:

    • Byte-based operation of I/O interfaces: InputStream and OutputStream
    • I/O interfaces based on character manipulation: writer and reader
    • Disk operation-based I/O interface: File
    • Network operation-based I/O interface: Socket

The first two groups are mainly data transmission data format, the latter two groups are mainly the way to transfer data.

1.1 Byte-based operation of I/O interfaces InputStream and OutputStream

InputStream Interface Common methods:

int read ();

int available ();

int Read (byte[] b);

int read (byte[] b,int off,int L);

OutputStream Interface Common methods:

Close ();

Flush ();

Writer (byte[] b);

Writer (byte[] b,int off,int L);

1.2 Interface for character-based I/O operations: Writer and reader.

The minimum storage unit for I/O operations is bytes, but because of the characters that are commonly manipulated in our programs, I/O methods for manipulating characters are provided.

Writer interface Common methods:

Writer (byte[] b);

Writer (byte[] b,int setoff,int L);

Writer (String S,int setoff,int L);

writer (int i);

Flush ();

Close ();

Reader interface Common methods:

int read ();

int read (byte[] b);

int read (byte[] b,int setoff,int L);

void Close ();

1.3 byte-to-character conversion interface

Data persistence or network transmission is done in bytes, so you know how to convert between bytes and characters.


InputStreamReader class

tab )

Preliminary discussion on Java I/O working mechanism

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: 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.