FileDocCategorySizeDatePackage
SimpleSaver.javaAPI DocExample854Tue Jun 03 23:32:40 BST 1997None

SimpleSaver.java

// This example is from the book Developing Java Beans by Robert Englander. 
// Copyright (c) 1997 O'Reilly & Associates.
// You may study, use, modify, and distribute this example for any purpose.
// This example is provided WITHOUT WARRANTY either expressed or implied.

// Chapter 5 -- The SimpleSaver class

import java.applet.*;
import java.awt.*;
import java.io.*;

public class SimpleSaver extends Applet
{
   public void init()
   {
      Button b = new Button("Beans Book");
      b.setFont(new Font("System", Font.BOLD, 36));
      add(b);
      try
      {
         FileOutputStream f = new FileOutputStream("Saver.tmp");
         ObjectOutput s = new ObjectOutputStream(f);
         s.writeObject(b);
         s.flush();
      }
      catch (Exception e)
      {
        System.out.println(e);
      }
   }
}