JAVA | Explain stream and various types of streams.

Stream: 
1. A stream in java is path along which data flows.
2. A stream is an abstraction that either produces or consumes information (i.e. it takes the input or gives the output).
3. A stream presents a uniform, easy-to-use, object oriented interface between program and input/output device.
4. It has source and destination. 

Java defines two types of streams: based on the datatype on which they operate: 

1. Byte Stream: Byte streams provide a convenient means for handling input and output of bytes. Byte streams are used, for example, when reading or writing binary data.  
2. Character stream: Character streams provide a convenient means for handling input and output of characters. They use Unicode and, therefore, can be internationalized. Also, in some cases, character streams are more efficient than byte streams. 

Post a Comment

0 Comments