Java Reference
In-Depth Information
I want to make a few comments about the DeserializeDemo program:
The try/catch block tries to catch a ClassNotFoundException, which is
declared by the readObject() method. For a JVM to be able to deserialize
an object, it must be able to find the bytecode for the class. If the JVM
can't find a class during the deserialization of an object, it throws a
ClassNotFoundException.
■■
Notice that the return value of readObject() is cast to an Employee
reference.
■■
The value of the SSN field was 11122333 when the object was serialized,
but because the field is transient, this value was not sent to the output
stream. The SSN field of the deserialized Employee object is 0.
■■
The Logging APIs
Version 1.4 of the J2SE introduced a new package called java.util.logging that
provides classes and interfaces for logging information about an application,
such as errors, problems, security breaches, performance bottlenecks, and so
on. The classes are referred to as the Logging APIs, and the process of logging
an event involves the following classes:
Logger. The Logger class creates the LogRecord objects and passes them
to a Handler.
LogRecord. This class contains the information to be logged.
Handler. This class formats the LogRecord into a specific format, such
as plaintext or XML, using a Formatter, and publishes the record to an
output stream.
Formatter. This class is responsible for formatting a LogRecord into a
specific format.
You can write your own Formatter class, or you can use one of the two
provided in the java.util.logging package:
SimpleFormatter. Formats the LogRecord into simple text.
XMLFormatter. Formats the LogRecord into an XML document of type
<log>, using a standard XML set of tags.
The Formatter gets associated with a Handler, which publishes the
LogRecord. There are several types of built-in Handler classes, including:
ConsoleHandler. Sends the formatted log record to System.err, which in
Windows is the console.
FileHandler.
Sends the formatted log record to a file.
Search WWH ::




Custom Search