Inputs and outputs-data sources and target media
The terms "input" and "output" are sometimes confusing. An application's input is often the output of another application. So is the OutputStream stream a stream that outputs to a destination, or a stream that produces output? Will the Inputsteam stream output its data to the program that reads the data? These questions are really confusing for beginners.
The input stream can be understood as input to memory, and the output stream can be understood as output from memory.
Java's IO package focuses on reading from the original data source and outputting the raw data to the target medium. The following are the most typical data sources and target vectors:
. file
. Piping
. Network Connections
. Memory Cache
. System.in,system.out,system.error (Note: Java standard input, output, error output)
The following diagram depicts the principle that a program reads data from a data source and then outputs the data to another medium:
Flow
In Java io, a stream is a core concept. A stream is conceptually a continuous stream of data. You can either read data from six or write data to the stream. The stream is associated with the data source or the medium in which the data flows. In Java IO, it can be either a stream of bytes (read and write in bytes) or a character stream (read and write in characters).
Class Inputstream,outputstream,reader and writer
A program requires Inputsteam or reader to read data from a data source, requiring OutputStream or writer to write data to the target medium. The following figure illustrates this:
InputStream and reader are associated with the data source,
OutputStream and writer are associated with the target medium.
Purpose and characteristics of Java IO
Java IO contains a number of InputStream, OutputStream, Reader, and writer subclasses. The reason for this design is that each class is responsible for a different function. That's why there are so many different classes in IO packets. Summary of various uses are as follows:
. File access
. Network access
. Memory Cache Access
. Thread internal communication (pipeline)
. buffering
. filter
. parsing
. Read and write text (readers/writers)
. Read and write basic type data (Long,int etc.)
. Read and Write objects
After reading through the source code of the Java IO class, it is easy to understand these uses. These uses are more or less easy to understand, with different classes targeting different business scenarios.
Java IO class overview table
The Java IO classes for data sources, target vectors, inputs, outputs, and various uses have been discussed, followed by a style of most Java IO classes that are divided by input, output, byte-or character-based, and other specific uses such as buffering and parsing.
This article references from: http://ifeve.com/java-io-3/
Java IO Overview