Java IO Streams
Overview
In this tutorial, we will learn Java IO Streams. A stream is a flow of data from the data source to the data destination, a logical connection between two areas/resources. The data is read from the data source and written to the data destination.
IO Streams
Streams can be divided into two main types Byte streams and Character streams. All the stream classes are defined in the java.io package. We need to import from this package the classes whenever we use stream classes in the Java program.
Byte Stream
Byte streams use plain bytes like in ASCII (8-bit) format and are mostly suited for standalone Java applications. Byte streams can be done using two classes:
- InputStream
- OutputStream
When the data is read ( the flow is towards the Java program) it is called InputStream. The InputSream is an abstract superclass of all classes representing an input stream of bytes.
When the data is stored or written (flow is outwards or away from the Java program) it is called OutputStream. The OutputStream is an abstract superclass of all classes representing an output stream of bytes.
Both InputStream and OutputStream classes are abstract and cannot be instantiated. The System class defines three stream objects for communication with standard I/O devices.
https://www.testingdocs.com/keyboard-interaction-in-java/
Character Stream
Character streams are the flow of characters for example Unicode (UTF-16/ 16-bit encoding) format. Character streams can be done using two classes:
- Reader
- Writer
Character streams are suitable for standalone as well as in web applications.
—
Java Tutorials
Java Tutorial on this website:
https://www.testingdocs.com/java-tutorial/
For more information on Java, visit the official website :