[J2SE Fast Forward] - Introduction to IO Streams
Copyright: This is an original post by the blogger and may not be reproduced without the blogger's permission. https://blog.csdn.net/huyuyang6688/article/details/43762149
IO flow is an abstraction of data flowing from one place to another, like water flowing from one end of a pipe to the other. In a program, all data is transferred and saved as a stream.
All of the stream classes provided by the JDK are located in the java.io package, and they all inherit from each of the following four abstract stream classes: InputStream, OutputStream, Reader, and Writer.
InputStream: streams that inherit from InputStream are used to input data into the program, and all data units are bytes (8 bits). OutputStream：inherited fromOutputStream The streams are all used by the program to output data to the outside， and the data units are all bytes（8 location）。 Reader：inherited fromReader The streams are all used to input data into the program， and the data units are all characters（16 location）。 Writer：inherited fromWriter The streams are all used by the program to output data to the outside， and the data units are all characters（16 location）。
★ Classified by flow direction, IO flow's can be classified as input stream harmony output stream . In general, the input and output of data are considered from the program's point of view, so the input stream is when the program reads data from the file, i.e., the data flows from the file to the program; the output stream is when the data is made to flow from the program to the file.
★ press transmission unit come to a classification，IO Streams can be divided into byte stream harmony character stream . As the name implies, byte streams transfer data in bytes as the basic unit, and character streams transfer data in Unicode characters that occupy 2 bytes as the basic unit. That said, recall the basics by the way: 1Byte(byte) = 8bit(bit), because characters in Java are encoded in Unicode, each character takes up two bytes, and the storage space occupied by each basic data type in Java is.
Storage space occupied
byte stream Can be used for any types object of， Includes binary objects， but (not) character stream Can only handle characters or strings； 2. byte stream Provides the ability to handle any types ofIO Function of operation， But it can't handle directlyUnicode word-symbol， but (not) character stream will be able to。
When it is understood that by flow harmony transmission unit When these two classifications are made, they can be viewed in combination with that mind map above.