Java The Complete Reference, Seventh Edition

(Greg DeLong) #1

27 NIO, Regular Expressions, and Other Packages


W


hen Java was originally released, it included a set of eight packages, called
thecore API.Each subsequent release added to the API. Today, the Java API
contains a large number of packages. Many of the new packages support areas
of specialization that are beyond the scope of this book. However, five packages warrant
an examination here:java.nio,java.util.regex,java.lang.reflect,java.rmi, andjava.text.
They support NIO-based I/O, regular expression processing, reflection, Remote Method
Invocation (RMI), and text formatting, respectively.
TheNIOAPI offers a different way to look at and handle certain types of I/O operations.
Theregular expressionpackage lets you perform sophisticated pattern matching operations.
This chapter provides an in-depth discussion of both of these packages along with extensive
examples.Reflectionis the ability of software to analyze itself. It is an essential part of the
Java Beans technology that is covered in Chapter 28.Remote Method Invocation (RMI)allows
you to build Java applications that are distributed among several machines. This chapter
provides a simple client/server example that uses RMI. Thetext formattingcapabilities of
java.texthave many uses. The one examined here formats date and time strings.

The Core Java API Packages


Table 27-1 lists all of the core API packages defined by Java and summarizes their functions.

813


Package Primary Function
java.applet Supports construction of applets.
java.awt Provides capabilities for graphical user inter faces.
java.awt.color Supports color spaces and profiles.
java.awt.datatransfer Transfers data to and from the system clipboard.
java.awt.dnd Supports drag-and-drop operations.
java.awt.event Handles events.

TABLE 27-1 The Core Java API Packages
Free download pdf