0% found this document useful (0 votes)
49 views

GIN222 Applied Programming For Engineers

This document discusses files and streams in Java. It explains that Java's java.io package offers classes for reading and writing streams of both character and byte data. It notes that Reader/Writer and InputStream/OutputStream are used for character and byte streams respectively. For text files, BufferedReader and BufferedWriter are recommended over Reader and Writer as they allow manipulating the file one character at a time.

Uploaded by

Nabih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

GIN222 Applied Programming For Engineers

This document discusses files and streams in Java. It explains that Java's java.io package offers classes for reading and writing streams of both character and byte data. It notes that Reader/Writer and InputStream/OutputStream are used for character and byte streams respectively. For text files, BufferedReader and BufferedWriter are recommended over Reader and Writer as they allow manipulating the file one character at a time.

Uploaded by

Nabih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

GIN222

Applied programming for engineers


Files and Streams
• When information is stored in a separated file,
a program needs to open a stream on it in
order to be able read it.
• A program can also open a stream to write in
a file.
Files and Streams
• In java the java.io package is available and
offers a collection of stream classes for
reading and writing.
• To use these classes, a program needs to
import the java.io package.
• The stream classes are divided into two class
hierarchies, based on the data type (either
characters or bytes) on which they operate
Character Stream and Byte Stream.
Files and Streams
• Reader and Writer are the abstract
superclasses used for 16-bit character streams
in java.
• To read and write 8-bit bytes, programs
should use the byte streams, descendents of
InputStream and OutputStream, typically used
to read and write binary data such as images
and sounds.
Files and Streams
• We are only interested in the manipulation of
text files.
• The Reader and the Writer allowing only the
manipulation of one character at a time, it is
often better to use the BufferedReader and
the BufferedWriter.

You might also like