What is IO package in java and what it consist of?
The IO package in java written as java.io consist of all classes you might ever need to perform input and output operation. In short it consist of input stream and output stream. The stream supports many data such as primitive, localized characters, object etc.
The Inputstream is used to read the source while the outputstream is used for writing data in destination. Byte stream in java is used for input output operation on 8-bit byte. the character stream is used for 16-bit Unicode.
Standard stream in java consist of Standard input, Standard outout, Strandard error which is similar to STDIN, STDOUT and STDERR in c++.
Standard Input: This is used to feed data to users program.
Standard Output: This is used to output the data produced.
Standard Error: This is used to output the error.
Java.IO package provides classes for system input and output through data streams,serialization and file system.It is used process the input and produce the output.Java uses the concept of stream to make I/O operation fast.The java.io package contains all the classes required for input and output operations.We can perform file handling in java by Java I/O API.
We have stream in this package which is a sequence of data.And it is composed of bytes.It is called stream because it is like a stream of water that continues to flow.
In,Java 3 streams are created automatically .All these streams are attached with console.
1.System.out:Standard output stream
Java application uses this to write data to destination.It may be file,an array or peripheral device.
2.System.in:Standard input stream
Java application uses this to read data from a source.It can also be a file,an array or socket.
3.System.err:Standard error stream