Name
Package java.io
Synopsis
The java.io package
is large,
but
most of the classes it contains fall into a well-structured
hierarchy. Most of the package consists of byte
streams—subclasses of InputStream or
OutputStream and character
streams—subclasses of
Reader or Writer. Each of these
stream subtypes has a specific purpose, and, despite its size,
java.io is a straightforward package to understand
and to use. In Java 1.4, the java.io package was
complemented by a “New I/O API”
defined in the java.nio package and its
subpackages. The java.nio package is totally new,
although it included some compatibility with the classes in this
package. It was designed for high-performance I/O, particularly for
use in servers and has a lower-level API than this package does. The
I/O facilities of java.io are still quite adequate
for most of the I/O required by typical client-side applications.
Before we consider the stream classes
that comprise the bulk of this package, let’s
examine the important nonstream classes. File
represents a file or directory name in a system-independent way and
provides methods for listing directories, querying file attributes,
and renaming and deleting files.
FilenameFilter
is an interface that defines a method
that accepts or rejects specified filenames. It is used by
File to specify what types of files should be
included in directory listings.
RandomAccessFile
allows you to read from or write to arbitrary locations of a file. Often, though, you’ll prefer sequential ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access