Java Reference
In-Depth Information
ZipInputStream and ZipOutputStream. This is used for working with
ZIP files. These classes are found in the java.util.zip package.
JarInputStream and JarOutputStream. This is used for reading and writ-
ing to JAR files. These classes are found in the java.util.jar package.
ProgressMonitorInputStream. This monitors the progress of an input
stream, and displays a dialog window to the user if the input is taking
too long, allowing the user to cancel the input stream. This class is in the
javax.swing package.
The J2SE contains an API known as the Image I/O API for reading and
writing images. The classes and interfaces of the Image I/O API are found
in the javax.imageio packages. If you are working with images, be sure to
check the documentation for a description of the various streams
available in this API.
Classroom Q & A
Q: Why make the distinction between low-level and high-level
streams? Why not just use the stream you want?
A: Because you often need to use both a low-level stream and one
or more high-level streams. The high-level streams perform the
type of I/O that you typically need done in an application, similarly
to reading and writing primitive data types or objects, while the
low-level stream communicates the actual source of the data, sim-
ilarly to the file or network socket.
Q: But if I want to read from a file, don't I need to use the low-level
FileInputStream class?
A: Yes, if the data in the file is to be read in as bytes. (If it contains
character data, you would likely use the FileReader class.)
Q: But the FileInputStream class only reads in data as bytes, so can I
only read in bytes at a time?
A: No, you can take the FileInputStream and chain it to a high-level
filter like the DataInputStream, which converts the bytes into primi-
tive data types.
Q: Why not just start with a DataInputStream?
A: You can't. A DataInputStream cannot attach to a file or any other
physical resource. The high-level streams are not instantiated on
their own. They require the existence of either a low-level stream
or some other existing high-level stream.
Search WWH ::




Custom Search