diff --git a/ImageJ/EPICS_areaDetector/EPICS_NTNDA_Viewer.java b/ImageJ/EPICS_areaDetector/EPICS_NTNDA_Viewer.java index 4b3e935..25b342d 100755 --- a/ImageJ/EPICS_areaDetector/EPICS_NTNDA_Viewer.java +++ b/ImageJ/EPICS_areaDetector/EPICS_NTNDA_Viewer.java @@ -19,6 +19,9 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; @@ -829,17 +832,22 @@ private void logMessage(String message, boolean logDisplay, boolean logFile) private void readProperties() { - String temp, path = null; + String temp = null; + Path path = Paths.get(System.getProperty("user.home"), ".config"); try { - String fileSep = System.getProperty("file.separator"); - path = System.getProperty("user.home") + fileSep + propertyFile; - FileInputStream file = new FileInputStream(path); + // If the .config directory does not exist, move back up to the home dir + if (!Files.exists(path)){ + path = path.getParent(); + } + path = Paths.get(path.toString(), propertyFile); + + FileInputStream file = new FileInputStream(path.toString()); properties.load(file); file.close(); temp = properties.getProperty("channelName"); if (temp != null) channelName = temp; - IJ.log("Read properties file: " + path + " channelName= " + channelName); + IJ.log("Read properties file: " + path.toString() + " channelName= " + channelName); } catch (Exception ex) { @@ -849,16 +857,20 @@ private void readProperties() private void writeProperties() { - String path; + Path path = Paths.get(System.getProperty("user.home"), ".config"); try { - String fileSep = System.getProperty("file.separator"); - path = System.getProperty("user.home") + fileSep + propertyFile; + // If the .config directory does not exist, move back up to the home dir + if (!Files.exists(path)){ + path = path.getParent(); + } + path = Paths.get(path.toString(), propertyFile); + properties.setProperty("channelName", channelName); - FileOutputStream file = new FileOutputStream(path); + FileOutputStream file = new FileOutputStream(path.toString()); properties.store(file, "EPICS_NTNDA_Viewer Properties"); file.close(); - logMessage("Wrote properties file: " + path, true, true); + logMessage("Wrote properties file: " + path.toString(), true, true); } catch (Exception ex) {