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 java.io, 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