In this tutorial, we will learn about Java input/output streams and their sorts.
In Java, streams are the sequence of data that are read from the source and kept in touch with the destination.
An input stream is used to peruse data from the source. Also, an output stream is used to write data to the destination.
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
For instance, in our first Hello World example, we have used System.out to print a string. Here, the System.out is a type of output stream.
Also, there are input streams to take input.
We will learn about input streams and output streams in detail in the later tutorials.
Types of Streams
Depending upon the data a stream holds, it can be classified into:
- Byte Stream
- Character Stream
Byte Stream
The byte stream is used to peruse and write a single byte (8 bits) of data.
All byte stream classes are gotten from base abstract classes called InputStream and OutputStream.
To learn more, visit
Character Stream
Character stream is used to peruse and write a single character of data.
All the character stream classes are gotten from base abstract classes Reader and Writer.
To learn more, visit
Thanks for reading! We hope you found this tutorial helpful and we would love to hear your feedback in the Comments section below. And show us what you’ve learned by sharing your photos and creative projects with us.