Managing Input

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

MANAGING INPUT /

OUTPUT FILES IN
JAVA
2
CONCEPTS OF STREAMS
I/O libraries often use the abstraction of a stream, which represents any
data source or sink as an object capable of producing or receiving pieces of
data.

The Java library classes for I/O are divided by input and output. You need to
import java.io package to use streams. There is no need to learn all the
streams just do it on the need basis.
• It is an abstraction of a data source/sink

• We need abstraction because there are lots of different


devices (files, consoles, network, memory, etc.). We need to
talk to the devices in different ways (sequential, random
access, by lines, etc.) Streams make the task easy by acting
in the same way for every device. Though inside handling of
devices may be quite different, yet on the surface
everything is similar. You might read from a file, the
keyboard, memory or network connection, different devices
may require specialization of the basic stream, but you can
treat them all as just "streams". When you read from a
network, you do nothing different than when you read from
a local file or from user's typing.
STREAM
CLASSES

5
6
IMPORTANT CLASSES OF BYTE STREAMS ARE: java.io.InputStream and
java.io.OutputStream. these are
abstract base classes for many subclasses.
1. InputStream
• ByteArrayInputStream
• FileInputStream
• PipedInputStream
• ObjectInputStream
• FilterInputStream

7
2. OutputStream
• ByteArrayOutputStream
• FileOutputStream
• PipedOutputStream
• ObjectOutputStream
• FilterOutputStream

8
9
FILE CLASS
11
THANK YOU

You might also like