Java.io.ObjectOutputStream.writeClassDescriptor() Method

Advertisements


Description

The java.io.ObjectOutputStream.writeClassDescriptor(ObjectStreamClass desc) method the specified class descriptor to the ObjectOutputStream. Class descriptors are used to identify the classes of objects written to the stream. Subclasses of ObjectOutputStream may override this method to customize the way in which class descriptors are written to the serialization stream. The corresponding method in ObjectInputStream, readClassDescriptor, should then be overridden to reconstitute the class descriptor from its custom stream representation. By default, this method writes class descriptors according to the format defined in the Object Serialization specification.

Declaration

Following is the declaration for java.io.ObjectOutputStream.writeClassDescriptor() method

protected void writeClassDescriptor(ObjectStreamClass desc)

Parameters

  • desc -- class descriptor to write to the stream

Return Value

This method does not return a value.

Exception

  • IOException -- if I/O errors occur while writing to the underlying stream

Example

The following example shows the usage of java.io.ObjectOutputStream.writeClassDescriptor() method.


Let us compile and run the above program, this will produce the following result:





Advertisements
Advertisements