io - Where to save a configuration file in a Java project -


so need client store server address etc... locally , have encrypted should file kept have tried putting in program files folder getting error. works fine on mac not windows.

 /**      * gets path configuration file      * dependent on operating system.      *       * @return file path {@code file}      */     public file getosconfigurationpath () {          file file;         if (system.getproperty("os.name").startswith("windows")) {             file = new file (system.getproperty("user.home") + "/program files/autosales/configuration.txt");         } else {             file = new file (system.getproperty("user.home") + "/library/application support/autosales/configuration.txt");         }          return file;     } 

the file ^^^^ returned uses this.

} else {                 file.createnewfile();                 system.out.println("new config file created");             } 

for reason windows save path give error.

enter image description here

any advice appreciated. thanks.

does exception occur on line windows file location or @ point later? such exception means code being executed more once , recursive repeating calls leads stack overflow.

the first thing here debug code , see when exception happens. once isolate code, able fix issue.

another note - using swingutilities.invokelater(runnable) when invoke ui related operations? must when deal java swing ui.

http://docs.oracle.com/javase/7/docs/api/javax/swing/swingutilities.html#invokelater(java.lang.runnable)

http://www.javamex.com/tutorials/threads/invokelater.shtml


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -