FileDocCategorySizeDatePackage
Blip3.javaAPI DocExample3995Mon Apr 06 18:10:24 BST 1998None

Blip3

public class Blip3 extends Object implements Externalizable

Fields Summary
int
i
String
s
Constructors Summary
public Blip3()

    System.out.println("Blip3 Constructor");
    // s, i not initialized
  
public Blip3(String x, int a)

    System.out.println("Blip3(String x, int a)");
    s = x;
    i = a;
    // s & i initialized only in non-default
    // constructor.
  
Methods Summary
public static voidmain(java.lang.String[] args)

    System.out.println("Constructing objects:");
    Blip3 b3 = new Blip3("A String ", 47);
    System.out.println(b3.toString());
    try {
      ObjectOutputStream o =
        new ObjectOutputStream(
          new FileOutputStream("Blip3.out"));
      System.out.println("Saving object:");
      o.writeObject(b3);
      o.close();
      // Now get it back:
      ObjectInputStream in =
        new ObjectInputStream(
          new FileInputStream("Blip3.out"));
      System.out.println("Recovering b3:");
      b3 = (Blip3)in.readObject();
      System.out.println(b3.toString());
    } catch(Exception e) {
      e.printStackTrace();
    }
  
public voidreadExternal(java.io.ObjectInput in)

    System.out.println("Blip3.readExternal");
    // You must do this:
    s = (String)in.readObject(); 
    i =in.readInt();
  
public java.lang.StringtoString()

 return s + i; 
public voidwriteExternal(java.io.ObjectOutput out)

    System.out.println("Blip3.writeExternal");
    // You must do this:
    out.writeObject(s); out.writeInt(i);