I. basic concepts of flow
P Input and output (I/O) is a problem that no language can avoid, and Java is no exception, such as: standard input and output, file operation, data flow on the network, string stream, object flow, etc. P If you design different input and output methods for different devices, it would be too much trouble. A flow mechanism is used in the Java language to solve the problem of input and output. Two.
Classification of StreamsP Character Stream: character-oriented streams, input and output data in character units, commonly used to manipulate character class files, such as text files. Because character streams are processed in characters, their efficiency is due to the byte stream. P Object Flow: An object-oriented stream that serializes an object in memory, or restores a serialized file to an in-memory object. The information and state of the object can be saved for a long time. Three.
InputStream Common methods
Pclose (): Off input stream Pread (): reads the next byte from the stream pread (byte[] b): reads some bytes from the input stream and deposits the array b pread (byte[] b, int off, int len) from the input stream to read the front len Byte and stored in array b four.
OutputStream Common MethodsPclose () closes the output stream Pwrite (byte[] b) writes B.length bytes from a specified byte array to this output stream. Pwrite (byte[] b, int off, int len) writes a specified byte array of len bytes from offset off to this output stream. Five.
Object Flow
In the Java language, we can save objects directly on the hard disk, and the references and related states in the object are persisted. We can re-read the copy of the hard disk into memory and restore it to the original object when needed. Pobjectinputstream: Object input stream pobjectoutputstream: Object output stream, note that in the process of saving an object from memory to a hard disk, we need to first convert the object into a byte stream to be saved, this process is called the object serialization. As long as the object implements the serializable interface, the process of reading from the hard disk to memory is called deserialization.
/ o