diff --git a/src/eva2/client/EvAClient.java b/src/eva2/client/EvAClient.java index 235c06f2..45b5762b 100644 --- a/src/eva2/client/EvAClient.java +++ b/src/eva2/client/EvAClient.java @@ -833,13 +833,13 @@ public class EvAClient implements RemoteStateListener, Serializable { JOptionPane.showMessageDialog(evaFrame.getContentPane(), "No modules available on " + comAdapter.getHostName(), EvAInfo.infoTitle, 1); } else { String lastModule = null; + try { - FileInputStream inputStream = new FileInputStream("lastmodule.ser"); - lastModule = Serializer.loadString(inputStream); - inputStream.close(); - } catch (Exception ex) { - LOGGER.log(Level.WARNING, "Could not load last loaded module.", ex); - } + java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userRoot(); + lastModule = prefs.get("lastModule", null); + } catch (SecurityException ex) { + LOGGER.log(Level.WARNING, "Can't write user preference.", ex); + } if (lastModule == null) { lastModule = ModuleNameList[0]; @@ -858,15 +858,12 @@ public class EvAClient implements RemoteStateListener, Serializable { if (selectedModule == null) { System.err.println("not loading any module"); - } else { + } else { try { - FileOutputStream outStream = new FileOutputStream("lastmodule.ser"); - Serializer.storeString(outStream, selectedModule); - outStream.close(); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not store selected module.", ex); - } catch (IOException ex) { - LOGGER.log(Level.WARNING, "Could not close file stream.", ex); + java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userRoot(); + prefs.put("lastModule", selectedModule); + } catch (SecurityException ex) { + LOGGER.log(Level.WARNING, "Can't write user preference.", ex); } loadSpecificModule(selectedModule, goParams); diff --git a/src/eva2/tools/jproxy/ComAdapter.java b/src/eva2/tools/jproxy/ComAdapter.java index 54e722e7..a8cbfe22 100644 --- a/src/eva2/tools/jproxy/ComAdapter.java +++ b/src/eva2/tools/jproxy/ComAdapter.java @@ -316,13 +316,10 @@ public class ComAdapter { public void setHostName(final String newHost) { hostName = newHost; try { - FileOutputStream fileStream = new FileOutputStream("hostname.ser"); - Serializer.storeString(fileStream, hostName); - fileStream.close(); - } catch (FileNotFoundException ex) { - LOGGER.log(Level.WARNING, "Could not write hostname to file.", ex); - } catch (IOException ex) { - LOGGER.log(Level.WARNING, "Error writing hostname to file.", ex); + java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userRoot(); + prefs.put("hostname", hostName); + } catch (SecurityException ex) { + LOGGER.log(Level.WARNING, "Can't write user preference.", ex); } }