The input and output capabilities of the Java language are very powerful and flexible, and the drawback is that the code that looks like input and output is not very concise, because you often need to wrap many different objects. In the Java class Library, the IO part of the content is very large, because it involves a wide range of areas: standard input and output, file operations, network data flow, string flow, object flow, zip file flow .... The purpose of this article is to give you a brief introduction.
Flow is a very graphic concept, when the program needs to read data, it will open a stream to the data source, this data source can be file, memory, or network connection. Similarly, when a program needs to write data, it opens a stream to the destination. At this point you can imagine that the data seems to be moving in this way, as in the following figure:
There are two kinds of streams in Java, one is the byte stream, the other is a stream of characters, which is represented by four abstract classes (each stream includes input and output, so altogether four): Inputstream,outputstream,reader,writer. Other streams of varying variations in Java are derived from them: