The job of a computer is to take an input and give an output, to us input is a feed that translated in a machine language and then displayed back as a readable format. Further

All Java data is written and read using streams.
  • A program opens a stream to a "data sink" where all the data reside.
  • A file is an example of a data sink.
  • A program opens a stream to allow data to be read into the routine or to be written "as data out to the file"

Types of Data

  • Character : stored with in a file with a suffix of Reader or Writer.
  • Raw Data : is saved to a data sink as bytes.
  • Formatted data : an image file is stored as formatted data.
  • Compressed Data
At the time of preparing this manuscript, Sun Micro conveyed the following items to deal with input-output of texts or objects.
  • I/O Streams
  • Byte Streams: carries integer values of the data added as an input. (1), ranging a value 0-255 and 32 being a blank or space between two data during serialization. All byte stream classes are the descendents of  InputStream and OutputStream (Read More). Java uses byte streams to perform input and output of 8-bit bytes. These classes are abstract classes, therefore can't be stream directly.
    • FileInputStream in = null;
    • FileOutputStream out = null;
      •  I/O byte streams, FileInputStream and FileOutputStream.
  • Character Streams: Any kind of text data handled by this stream. All character stream classes are descended from Reader and Writer.(Read More)
    • FileReader inputStream = null;
    • FileWriter outputStream = null;
  • Buffered Streams: the efficiency of the streams mentioned above, further  enhanced with Buffered stream.
    • There are four buffered stream classes used to wrap FileReader or Writer streams:
      •  Create buffered byte streams:
        • BufferedInputStream and BufferedOutputStream
      • Create buffered character streams
        •  BufferedReader and BufferedWriter.
  • Scanning and Formatting
    • Scanning
    • Formatting
  • I/O from the Command Line
  • Data Streams: support binary I/O of primitive data type values like boolean, char, byte, short, int, long, float, double and Strings. All data streams implement either the two interfaces namely DataInput  or the DataOutput interface. This section focuses on the most widely-used implementations of these interfaces, DataInputStream and DataOutputStream.
  • Object Stream
  • File I/O
    File Objects
    Random Access Files
    The New I/O Packages
 
An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and translates them into characters according to a specified character encoding. The encoding that it uses may be specified by name, or the platform's default encoding may be accepted.

Each invocation of one of an InputStreamReader's read() methods may cause one or more bytes to be read from the underlying byte-input stream. To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation.

For top efficiency, consider wrapping an InputStreamReader within a BufferedReader. For example:

 BufferedReader in
   = new BufferedReader(new InputStreamReader(System.in));


 

 
Types of Data Sinks: :

Data sink streams read from or write to specialized data sinks such as strings, files, or pipes. Typically, for each reader or input stream intended to read from a specific kind of input source, java.io contains a parallel writer or output stream that can create it. The following table gives java.io's data sink streams.

Sink Type Character Streams Classes Byte Streams Classes DataSink Classes
Memory CharArrayReader,
CharArrayWriter
ByteArrayInputStream,
ByteArrayOutputStream
ByteArrayInputStream,
ByteArrayOutputStream
StringReader,
StringWriter
StringBufferInputStream
Pipe PipedReader,
PipedWriter
PipedInputStream,
PipedOutputStream
PipedInputStream,
PipedOutputStream
File FileReader,
FileWriter
FileInputStream,
FileOutputStream
FileInputStream
FileOutputStream

Note that both the character stream group and the byte stream group contain parallel pairs of classes that operate on the same data sinks. These are described next:

The Character Filter Classes can be stacked on top of another data sink.

Sink Type Character Filter Classes
Buffer BufferedReader,
BufferedWriter
characters are stored in buffer and that can enhance performances of a routine.
Line Counting LineNumberReader : can be used to read lines from a data while indexing the line numbers.
Conversion InputStreamReader
InputStreamWriter
 
Printing PrintWriter can be used to print information to a source or computer screen

Data Filter Classes:

Sink Type Data Filter Classes
Compression GZIPInputStream,
GZIPOutputStream
ZIPInputStream
,
ZIPOutputStream
JARInputStream
,
JAROutputStream
Object ObjectInputStream,
ObjectOutputStream
Buffer BufferedInputStream
BufferedOutStream
Printing PrintWriter

 

Sink Type I/O Exceptions Class Hierarchy