Stream is a connection between Java Program and a File.
Stream is not a physical wired connection but a logical connection for transferring data.
Stream is a logical connection between java program and file either for reading or writing.
Basically there are two types of Streams :
- Input Stream
- Output Stream
These streams are from the java point of view i.e with respect to java. Hence we can say
– Input Stream w.r.t to java is give input to java program.
– Output Stream w.r.t to java is give output from java program.
Broadly there are 4 types of Streams in java :
- Binary Streams – For binary data – From java 1.0
- Input Stream (Abstract Class)
- Output Stream (Abstract Class)
- Characters Streams – For characters – From java 1.1
- Reader (Abstract Class)
- Writer (Abstract Class)
- Input and Output Stream are abstract class
- Since there are several sources to read data from and several destination to write data to hence we need several concrete classes which extends this abstract class and handle the logic.
List of Input Streams : (9 subclasses)
- FileInputStream (Read one byte Data from File as it is) (Important)
- ByteArrayInputStream (Read data inform of array)
- DataInputStream (Read one byte Data from File in primitive datatype)(Important)
- BufferedInputStream (Reading Fast )
- ObjectInputStream (Reading as a complete Object)(Important)
- PipedInputStream (Passing a Stream to another)
- SequenceInputStream (Read Data from multiple file)
List of Output Streams : (8 subclasses)