/** Here we actually have 2 programs: this Writer, and then a Reader. * Run this program first. It will create a vector (list) of various * shopping list items. Then it will write the list into a file for * later use by the other program. * We are treating this list as a "persistent object", which means it * can be used again after this program dies. */ import java.io.*; import java.util.*; public class Writer { public static void main(String [] args) throws IOException, FileNotFoundException { ObjectOutputStream out = new ObjectOutputStream (new FileOutputStream("shoppinglist.txt")); Vector list = new Vector(); list.add(new Item ("boat", 5000)); list.add(new Item ("phone", 22)); out.writeObject(list); out.close(); } }