예제 #1
0
 public static void storeDevices(Hashtable devices, String selected) {
   File cf = getConfigFile();
   if (cf == null) {
     return;
   }
   FileWriter fw = null;
   try {
     fw = new FileWriter(cf, false);
     for (Enumeration i = devices.keys(); i.hasMoreElements(); ) {
       String addr = (String) i.nextElement();
       DeviceInfo di = (DeviceInfo) devices.get(addr);
       fw.write(devicePrefix + di.saveAsLine() + "\n");
     }
     if (selected != null) {
       fw.write(selectedPrefix + selected + "\n");
     }
     for (Enumeration en = properties.propertyNames(); en.hasMoreElements(); ) {
       String name = (String) en.nextElement();
       fw.write(name + "=" + properties.getProperty(name) + "\n");
     }
     fw.flush();
   } catch (Throwable e) {
     Logger.debug(e);
     return;
   } finally {
     if (fw != null) {
       try {
         fw.close();
       } catch (IOException e) {
       }
     }
   }
 }