<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Interface java.io.Serializable
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.io.html">This Package</a>  <a href="java.io.ObjectOutput.html#_top_">Previous</a>  <a href="Package-java.io.html">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Interface java.io.Serializable
</h1>
<dl>
  <dt> public interface <b>Serializable</b>
</dl>
Serializability of a class is enabled by the class implementing the
 java.io.Serializable interface. Classes that do not implement this
 interface will not have any of their state serialized or
 deserialized.  All subtypes of a serializable class are themselves
 serializable.  The serialization interface has no methods or fields
 and serves only to identify the semantics of being serializable. <p>
 To allow subtypes of non-serializable classes to be serialized, the
 subtype may assume responsibility for saving and restoring the
 state of the supertype's public, protected, and (if accessible)
 package fields.  The subtype may assume this responsibility only if
 the class it extends has an accessible no-arg constructor to
 initialize the class's state.  It is an error to declare a class
 Serializable in this case.  The error will be detected at runtime. <p>
 During deserialization, the fields of non-serializable classes will
 be initialized using the public or protected no-arg constructor of
 the class.  A no-arg constructor must be accessible to the subclass
 that is serializable.  The fields of serializable subclasses will
 be restored from the stream. <p>
 When traversing a graph, an object may be encountered that does not
 support the Serializable interface. In this case the
 NotSerializableException will be thrown and will identify the class
 of the non-serializable object. <p>
 Classes that require special handling during the serialization and deserialization
 process must implement special methods with these exact signatures: <p>
 <PRE>
 private void writeObject(java.io.ObjectOutputStream out)
     throws IOException
 private void readObject(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException; 
 </PRE><p>
 The writeObject method is responsible for writing the state of the
 object for its particular class so that the corresponding
 readObject method can restore it.  The default mechanism for saving
 the Object's fields can be invoked by calling
 out.defaultWriteObject. The method does not need to concern
 itself with the state belonging to its superclasses or subclasses.
 State is saved by writing the individual fields to the
 ObjectOutputStream using the writeObject method or by using the
 methods for primitive data types supported by DataOutput. <p>
 The readObject method is responsible for reading from the stream and restoring
 the classes fields. It may call in.defaultReadObject to invoke
 the default mechanism for restoring the object's non-static and non-transient
 fields.  The defaultReadObject method uses information in the stream to
 assign the fields of the object saved in the stream with the correspondingly
 named fields in the current object.  This handles the case when the class
 has evolved to add new fields. The method does not need to concern
 itself with the state belonging to its superclasses or subclasses.
 State is saved by writing the individual fields to the
 ObjectOutputStream using the writeObject method or by using the
 methods for primitive data types supported by DataOutput. <p>
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.io.ObjectOutputStream.html#_top_">ObjectOutputStream</a>, <a href="java.io.ObjectInputStream.html#_top_">ObjectInputStream</a>, <a href="java.io.ObjectOutput.html#_top_">ObjectOutput</a>, <a href="java.io.ObjectInput.html#_top_">ObjectInput</a>, <a href="java.io.Externalizable.html#_top_">Externalizable</a>
</dl>
<hr>
<a name="index"></a>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.io.html">This Package</a>  <a href="java.io.ObjectOutput.html#_top_">Previous</a>  <a href="Package-java.io.html">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
