THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1
Thrown when the validateObject method cannot make the object valid,
thus aborting the deserialization.

NotActiveExceptionextends ObjectStreamException

Thrown when a serialization method, such as defaultReadObject, is
invoked when serialization is not under way on the stream.

NotSerializableExceptionextends ObjectStreamException

Thrown either by the serialization mechanism or explicitly by a class when a
class cannot be serialized.

ObjectStreamExceptionextends IOException

The superclass for all the Object stream related exceptions.

OptionalDataExceptionextends ObjectStreamException

Thrown when the optional data (that is, not part of default serialization) in the
object input stream is corrupt or was not read by the reading method.

StreamCorruptedExceptionextends ObjectStreamException

Thrown when internal object stream state is missing or invalid.

SyncFailedExceptionextends IOException

Thrown by FileDescriptor.sync when the data cannot be guaranteed
to have been written to the underlying media.

UnsupportedEncodingExceptionextends IOException

Thrown when an unknown character encoding is specified.

UTFDataFormatExceptionextends IOException

Thrown by DataInputStream.readUTF when the string it is reading
has malformed UTF syntax.

WriteAbortedExceptionextends ObjectStreamException

Thrown when an exception occurred during a serialization write operation.

In addition to these specific exceptions, other exceptional conditions in java.io are signaled with an
IOException containing a string that describes the specific error encountered. For example, using a
Piped stream object that has never been connected throws an exception object with a detail string such as
"Pipenotconnected", and trying to push more than the allowed number of characters onto a
PushbackReader tHRows an exception with the string "Pushbackbufferoverflow". Such
exceptions are difficult to catch explicitly, so this style of exception reporting is not in favor. Specific
exception subtypes should be created for each category of exceptional circumstance.

Free download pdf