Module 10 Input and Output Stream
Module 10 Input and Output Stream
(Java)
Module 10
Input and Output Stream
Learn how to read from input streams and write to
output streams
Learn how to write a text and binary files
InputStream and OutputStream
10.1
Ø Let's see the code to print output and an error message to the
console.
Ø OutputStream
Ø Java application uses an output stream to write data to a
destination; it may be a file, an array, peripheral device or
socket.
Ø InputStream
Ø Java application uses an input stream to read data from a
source; it may be a file, an array, peripheral device or socket.
Ø OutputStream Class
Ø Java OutputStream class is an abstract class. It is the
superclass of all classes representing an output stream of
bytes. An output stream accepts output bytes and sends them
to some sink.
Ø OutputStream Hierarchy
Ø InputStream Hierarchy
testout.txt
testout.txt
Output:
Input and
FileWriter andOutput Stream
FileReader
Java FileWriter Class
Ø Java FileReader class is used to read data from the file. It returns
data in byte format like FileInputStream class.
Ø It is character-oriented class which is used for file handling
in java.
Ø Java.io.FileReader