outputstream - Java properties file is saved in system32 folder -


so, have method saves data in properties file weird happens. see, lets have jar file on desktop. if open directly there (double click, etc) properties file saved in desktop, should be. however, if drag jar windows start list , open there, properties file saved in system32 folder.

here method:

private void saveancientsdata() {         properties prop = new properties();         outputstream output = null;          try {              output = new fileoutputstream("ancients.data");             file file = new file("ancients.data");             // set properties value             (int x = 0; x < currentlvlspinnerfields.size(); x++) {                 prop.setproperty(ancientnames[x], currentlvlspinnerfields.get(ancientnames[x]).getvalue().tostring());             }              // save properties project root folder             prop.store(output, null);             joptionpane.showmessagedialog(this, "data saved in \n\n" + file.getcanonicalpath(), "saved", joptionpane.information_message);         } catch (ioexception io) {             io.printstacktrace();         } {             if (output != null) {                 try {                     output.close();                 } catch (ioexception e) {                     e.printstacktrace();                 }             }         }     } 

would appreciate help, since clueless.

thanks in advance!

according code haven't give path of property file create in desktop.

output = new fileoutputstream("ancients.data"); 

so property file created in same directory jar file exists .

but if run .jar file parent process jar file created in directory parent process exists.

i guess when windows starts specific process exist in win32 directory execute start-up programs .i think it's userinit.exe . prop file created in system32 directory .

if want property file create in desktop can put jar file in desktop , add shortcut .jar or can give full-path desktop like

output = new fileoutputstream(system.getproperty("user.home") + "/desktop/"+"ancients.data"); 

edit

to understand problem

1) create folder named example in desktop.and create 2 folders path1 , path2 .then add .jar path1 folder

enter image description here

2) double click jar in path1 .and property file created in path1 expected .

enter image description here

3) delete property file.open command prompt in path2 . run prop.jar file in path1 . type call "pathtodesktop/example/path1/prop.jar" hit enter.

.property file created in path2 instead of path1 that's happening in case.

enter image description here


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -