appendix C

The Java Class Library

by Laura Lemay


This appendix provides a general overview of the classes available in the standard Java packages (that is, the classes that are guaranteed to be available in any Java implementation). This appendix is intended for general reference; for more information about class inheritance and the exceptions defined for each package, see appendix B, "Class Hierarchy Diagrams." For more specific information about each class and the methods within each class, see the API documentation from Sun at http://java.sun.com. A copy of the 1.0 API documentation is on the CD-ROM included with this book.


The java.lang package contains the classes and interfaces that make up the core Java language.


CloneableInterface indicating that an object may be copied or cloned
Runnable Methods for classes that want to run as threads


Boolean Object wrapper for boolean values
Character Object wrapper for char values
Class Runtime representations of classes
ClassLoader Abstract behavior for handling loading of classes
Compiler System class that gives access to the Java compiler
Double Object wrapper for double values
Float Object wrapper for float values
Integer Object wrapper for int values
Long Object wrapper for long values
Math Utility class for math operations
Number Abstract superclass of all number classes (Integer, Float, and so on)
Object Generic Object class, at top of inheritance hierarchy
Process Abstract behavior for processes such as those spawned using methods in the System class
Runtime Access to the Java runtime
SecurityManager Abstract behavior for implementing security policies
String Character strings
StringBuffer Mutable strings
System Access to Java's system-level behavior, provided in a platform-independent way
Thread Methods for managing threads and classes that run in threads
ThreadDeath Class of object thrown when a thread is asynchronously terminated
ThreadGroup A group of threads
Throwable Generic exception class; all objects thrown must be a Throwable


The java.util package contains various utility classes and interfaces, including random numbers, system properties, and other useful classes.


Enumeration Methods for enumerating sets of values
Observer Methods for allowing classes to observe Observable objects


BitSet A set of bits
Date The current system date, as well as methods for generating and parsing dates
Dictionary An abstract class that maps between keys and values (superclass of HashTable)
HashTable A hash table
Observable An abstract class for observable objects
Properties A hash table that contains behavior for setting and retrieving persistent properties of the system or of a class
Random Utilities for generating random numbers
Stack A stack (a last-in-first-out queue)
StringTokenizer Utilities for splitting strings into a sequence of individual "tokens"
Vector A growable array of Objects


The java.io package provides input and output classes and interfaces for streams and files.


DataInput Methods for reading machine-independent typed input streams
DataOutput Methods for writing machine-independent typed output streams
FilenameFilter Methods for filtering filenames


BufferedInputStream A buffered input stream
BufferedOutputStream A buffered output stream
ByteArrayInputStream An input stream from a byte array
ByteArrayOutputStream An output stream to a byte array
DataInputStream Enables you to read primitive Java types (ints, chars, booleans, and so on) from a stream in a machine-independent way
DataOutputStream Enables you to write primitive Java data types (ints, chars, booleans, and so on) to a stream in a machine-independent way
File Represents a file on the host's file system
FileDescriptor Holds onto the UNIX-like file descriptor of a file or socket
FileInputStream An input stream from a file, constructed using a filename or descriptor
FileOutputStream An output stream to a file, constructed using a filename or descriptor
FilterInputStream Abstract class that provides a filter for input streams (and for adding stream functionality such as buffering)
FilterOutputStream Abstract class that provides a filter for output streams (and for adding stream functionality such as buffering)
InputStream An abstract class representing an input stream of bytes; the parent of all input streams in this package
LineNumberInputStream An input stream that keeps track of line numbers
OutputStream An abstract class representing an output stream of bytes; the parent of all output streams in this package
PipedInputStream A piped input stream, which should be connected to a PipedOutputStream to be useful
PipedOutputStream A piped output stream, which should be connected to a PipedInputStream to be useful (together they provide safe communication between threads)
PrintStream An output stream for printing (used by System.out.println(...))
PushbackInputStream An input stream with a 1-byte push-back buffer
RandomAccessFile Provides random access to a file, constructed from filenames, descriptors, or objects
SequenceInputStream Converts a sequence of input streams into a single input steam
StreamTokenizer Converts an input stream into a sequence of individual tokens
StringBufferInputStream An input stream from a String object


The java.net package contains classes and interfaces for performing network operations, such as sockets and URLs.


ContentHandlerFactory Methods for creating ContentHandler objects
SocketImplFactory Methods for creating socket implementations (instance of the SocketImpl class)
URLStreamHandlerFactory Methods for creating URLStreamHandler objects


ContentHandler Abstract behavior for reading data from a URL connection and constructing the appropriate local object, based on MIME types
DatagramPacket A datagram packet (UDP)
DatagramSocket A datagram socket
InetAddress An object representation of an Internet host (host name, IP address)
ServerSocket A server-side socket
Socket A socket
SocketImpl An abstract class for specific socket implementations
URL An object representation of a URL
URLConnection Abstract behavior for a socket that can handle various Web-based protocols (http, ftp, and so on)
URLEncoder Turns strings into x-www-form-urlencoded format
URLStreamHandler Abstract class for managing streams to object referenced by URLs


The java.awt package contains the classes and interfaces that make up the Abstract Windowing Toolkit (awt).


LayoutManager Methods for laying out containers
MenuContainer Methods for menu-related containers


BorderLayout A layout manager for arranging items in border formation
Button A UI pushbutton
Canvas A canvas for drawing and performing other graphics operations
CardLayout A layout manager for HyperCard-like metaphors
Checkbox A check box
CheckboxGroup A group of exclusive check boxes (radio buttons)
CheckboxMenuItem A toggle menu item
Choice A pop-up menu of choices
Color An abstract representation of a color
Component The abstract generic class for all UI components
Container Abstract behavior for a component that can hold other components or containers
Dialog A window for brief interactions with users
Dimension An object representing width and height
Event An object representing events caused by the system or based on user input
FileDialog A dialog for getting filenames from the local file system
FlowLayout A layout manager that lays out objects from left to right in rows
Font An abstract representation of a font
FontMetrics Abstract class for holding information about a specific font's character shapes and height and width information
Frame A top-level window with a title
Graphics Abstract behavior for representing a graphics context, and for drawing and painting shapes and objects
GridBagConstraints Constraints for components laid out using GridBagLayout
GridBagLayout A layout manager that aligns components horizontally and vertically based on their values from GridBagConstraints
GridLayout A layout manager with rows and columns; elements are added to each cell in the grid
Image An abstract representation of a bitmap image
Insets Distances from the outer border of the window; used to lay out components
Label A text label for UI components
List A scrolling list
MediaTracker A way to keep track of the status of media objects being loaded over the Net
Menu A menu, which can contain menu items and is a container on a menu bar
MenuBar A menu bar (container for menus)
MenuComponent The abstract superclass of all menu elements
MenuItem An individual menu item
Panel A container that is displayed
Point An object representing a point (x and y coordinates)
Polygon An object representing a set of points
Rectangle An object representing a rectangle (x and y coordinates for the top corner, plus width and height)
Scrollbar A UI scrollbar object
TextArea A multiline, scrollable, editable text field
TextComponent The superclass of all editable text components
TextField A fixed-size editable text field
Toolkit Abstract behavior for binding the abstract awt classes to a platform-specific toolkit implemen-tation
Window A top-level window, and the superclass of the Frame and Dialog classes


The java.awt.image package is a subpackage of the awt that provides classes for managing bitmap images.


ImageConsumer Methods for receiving image data created by an ImageProducer
ImageObserver Methods to track the loading and construction of an image
ImageProducer Methods for producing image data received by an ImageConsumer


ColorModel An abstract class for managing color information for images
CropImageFilter A filter for cropping images to a particular size
DirectColorModel A specific color model for managing and translating pixel color values
FilteredImageSource An ImageProducer that takes an image and an ImageFilter object and produces an image for an ImageConsumer
ImageFilter A filter that takes image data from an ImageProducer, modifies it in some way, and hands it off to a ImageConsumer
IndexColorModel A specific color model for managing and translating color values in a fixed-color map
MemoryImageSource An image producer that gets its image from memory; used after constructing an image by hand
PixelGrabber An ImageConsumer that retrieves a subset of the pixels in an image
RGBImageFilter Abstract behavior for a filter that modifies the RGB values of pixels in RGB images


The java.awt.peer package is a subpackage of awt that provides the (hidden) platform-specific awt classes (for example, for Motif, Macintosh, or Windows 95) with platform-independent interfaces to implement. Thus, callers using these interfaces need not know which platform's window system these hidden awt classes are currently implementing.

Each class in the awt that inherits from either Component or MenuComponent has a corresponding peer class. Each of those classes is the name of the Component with -Peer added (for example, ButtonPeer, DialogPeer, and WindowPeer). Because each one provides similar behavior, they are not enumerated here.


The java.applet package provides applet-specific behavior.


AppletContext Methods to refer to the applet's context
AppletStub Methods for implementing applet viewers
AudioClip Methods for playing audio files


Applet The base applet class