A large part of network programs is simple input and output, that is, moving bytes from one system to another. Bytes are bytes. To a large extent, the data sent by the read server is no different from the data read from the file. There is no difference between transmitting data to the customer and writing a file.
In Java, input and output are organized differently from most other languages. It is built on a stream. Different Basic stream classes (such as java. io. FileInputStream and sun.net. TelnetOutputStream) are used to read and write specific data resources. However, all basic output streams read data using the same basic method.
A filter stream can be connected to an input stream or an output stream. It can modify the data that has been read or written to (for example, encrypted or compressed data), or simply provide additional methods to convert the data that has been read or written to another format.
Reader and Writer can also link to the input stream and output stream to allow the program to read and write text (that is, characters) rather than bytes. If used correctly, Reader and Writer can handle multiple types of character encoding, including multi-byte character sets such as SJIS and UTF-8.
I. output stream
The basic output stream of java is java. io. OutputStream.
Public abstract class OutputStream
N public abstract void write (int B) throws IOException
N public void write (byte [] data) throws IOException
N public void write (byte [] data, int offset, int length) throws IOException
N public void flush () throws IOException
N public void close () throws IOException
The subclass of OutputStream uses these methods to write data to the specified media.
I believe that when we understand what they exist, we will better remember them.