VersionObjectOutputStream.java

import java.io.*;
public class VersionObjectOutputStream extends ObjectOutputStream {
  String version;
  public VersionObjectOutputStream(OutputStream out, String version)
    throws IOException {
    super(out);
    this.version = version;
  }
  protected void annotateClass(Class cl) throws IOException {
    // Ajoute le numéro de la version de la classe dans le flot 
    this.writeObject(version);  }
  
  public static void main(String argv[]) throws IOException {
    VersionObjectOutputStream out =
      new VersionObjectOutputStream(System.out, "1.2");
    out.writeObject(new Liste(1, new Liste(2, null)));
    out.close();
  }
}