/** * Initialize PIM database file used by sample RMI server * * main creates a bunch of PIMEntities and saves a PIMCollection * in a file (serialized). * * This file is just used by the sample RMI server as * an initial PIMCollection to serve up via the remote * interface RemotePIMCollection */ import java.util.*; import java.io.*; class Initialize { /** * main creates some PIMEntity objects and adds them to * a PIMCollection. Then it writes the PIMCollection to a file. */ static public void main(String args[]) { PIMCollection pc = new PIMCollection(); PIMNote note; PIMAppointment appt; PIMTodo todo; PIMContact contact; pc.add( new PIMNote("Finish this code","High","DaveH",true)); pc.add( new PIMNote("Another Note","Medium","DaveH",false)); pc.add( new PIMNote("Notes are fun","Low","Joe Note",true)); pc.add( new PIMContact("Dave","Hollinger","hollingd@cs.rpi.edu", "none","DaveH",true)); pc.add( new PIMContact("Joe","Student","joe@student.edu", "none","DaveH",false)); pc.add( new PIMContact("Jane","Doe","jdoe@foo.com", "none","Mary",true)); pc.add( new PIMAppointment("Java Class", new Date(103,3,7), "Medium","DaveH",true)); pc.add( new PIMAppointment("Java Class", new Date(103,3,14), "Medium","DaveH",true)); pc.add( new PIMAppointment("Java Class", new Date(103,3,21), "Medium","DaveH",true)); pc.add( new PIMAppointment("Java Class", new Date(103,3,28), "Medium","DaveH",true)); pc.add( new PIMTodo("HW6", new Date(103,3,28), "High","DaveH",true)); pc.add( new PIMTodo("Work on Todo List", new Date(103,3,10), "Medium","DaveH",true)); writeCollection(pc,"pimdata"); } public static void writeCollection(PIMCollection c, String filename) { try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filename)); oos.writeObject(c); oos.close(); } catch (Exception e) { e.printStackTrace(); } } }