Esempio n. 1
0
 /**
  * Updates the file with the local user's information
  *
  * @param me The player
  */
 public static void updateMe(final Player me) {
   synchronized (monitor) {
     if (me != null) myDNSes = me.getDNSes();
     ObjectOutputStream os = null;
     try {
       os =
           new ObjectOutputStream(
               new BufferedOutputStream(new FileOutputStream(new File(myFile))));
       for (final String dns : myDNSes) {
         System.err.println("Saving DNS: " + dns);
         os.writeObject(dns);
       }
       System.err.println("Saving UUID: " + myUUID);
       os.writeObject(myUUID);
       os.flush();
     } catch (final IOException err) {
       System.err.println("Cannot save local user data: " + err.toString());
     } finally {
       if (os != null)
         try {
           os.close();
         } catch (final Throwable err) {
           // Do nothing
         }
     }
   }
 }
Esempio n. 2
0
 /** Updates the file with the friend information */
 private static void saveFriends() {
   synchronized (monitor) {
     System.err.println("saving: " + friends);
     ObjectOutputStream os = null;
     try {
       os =
           new ObjectOutputStream(
               new BufferedOutputStream(new FileOutputStream(new File(friendFile))));
       for (final Player friend : friends) os.writeObject(friend);
       os.writeObject(null);
       os.flush();
     } catch (final IOException err) {
       System.err.println("Cannot save local user data: " + err.toString());
     } finally {
       if (os != null)
         try {
           os.close();
         } catch (final Throwable err) {
           // Do nothing
         }
     }
   }
 }