Esempio n. 1
0
 /**
  * Saves the hashTable in the file specified by the <i>destination</i>. *
  *
  * @pre destination &ne; null AND location in file system where file is to be created exists AND
  *     the file location is writable AND every object in the ObjectDB is serializable.
  * @post the hashTable has been saved to the file named <i>destination</i> along with the size of
  *     the hashTable.
  */
 public void save(String destination) {
   String fileLocation = DEFAULT_FILE_LOCATION;
   if (FILE_LOCATION != null) {
     fileLocation = FILE_LOCATION;
   }
   if (destination != null) {
     fileLocation = destination;
   }
   try {
     ObjectOutputStream oos =
         new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(fileLocation)));
     oos.write(LocalObjectId.getNextId());
     oos.writeObject(hashTable);
     oos.flush();
     oos.close();
   } catch (Exception e) {
     System.err.println("In communicator.ObjectDB::save(String) -- ERROR could not save ObjectDB");
   }
 }