try {
  FileOutputStream fos = new
                     FileOutputStream("inventory.dat");
  ObjectOutputStream oos = new ObjectOutputStream(fos);
  oos.writeObject(inventory);
  fos.close();
} // end try
catch (Exception e) {
  System.out.println(e);
} // end catch
