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.
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.
Comments
Post a Comment