4 blocks to learn Java I/O.
Character-based: Inputstream,outputstream
BYTE-based: Writer,reader
Disk-based: File
Network-based: Socket
The first two are data formats for transmitting data, and the next two are the ways to transfer the data.
Have idea's classmate, follow me to do together, do not have a classmate, download installs well after follow me to do together. Don't want to do it together, imagine doing it with me.
1, CTRL + N, find InputStream this class, class name right-click Diagrams->show Diagram ...
2. Delete other classes, check inputstream,ctrl+alt+b, search for classes, add to diagram, repeat until all classes are loaded into.
3, the Virgo classmate please press F5, to alleviate the discomfort feeling. Please help yourself to a non-Virgo, but I also suggest you F5.
Then, each class is selected and pressed F4 to look at the comments ... Then ask the English good schoolmate to point out my translation the mistake place.
Objectinputstream:1, the goods deserialize those who were previously written by their good friends objectoutputstream primitive data or objects. Please use pairing. 2, this goods in addition to restore the base friends to do things, you can also use the socket between the host object, but also in the remote communication marshal and Unmarshal parameters and parameters. (own Baidu parameter and argument difference) 3, you want to serialize, you want the JVM to have the related class. 4, ReadObject read out their own strong turn into the required format, strting and arrays here is a serious object, as for those low-level primitive, will error. Primitive can be taken out using the appropriate method of Datainput. 6, transient and static will be ruthlessly ignored. Other classes referenced will also be read, deserialize always new application to put object. It is pure and will not pollute. No-arg constructors is invoked for the Non-serializable classes this sentence did not understand.
FileInputStream: Document Good understanding does not explain.
Bufferedinputstream: Can specify the size of a buffer, improve the transmission rate, the principle reminiscent of nio, in fact, some tests on the web also said that the performance is not very different from NIO, in two can achieve the purpose of the scene under the situation with the goods will be more simple.
DataInputStream: In fact, is the grammar of sugar, the bottom is transmitted by byte, the advantage of this goods can not remember the various primitive types accounted for a few pits, how to enter how out on the line.
PipedInputStream: Cross-Threading things, producer-consumer models.
In the same vein:
Internal through Stringencoder and charset conversion, turn out garbled words themselves to adjust the code.
Java IO (1)