Trying to get file paths to work across all releases in Java/Netbeans -


so i'm working on game, , need file i/o savefiles. have setup read them:

public static void savesmanagementmenu() {     (int = 1; < 4; i++) {         fileurl = jrpg.class.getresource("saves/save" + + ".txt");         system.out.println(fileurl);         if (fileurl != null) {             savemenusavefile = new file(fileurl.getpath());              try {                 //system.out.println("file # " + +" exists.");                 savemenusavefilereader = new filereader(fileurl.getpath());                 savemenufilescanner = new scanner(savemenusavefilereader);                  savemenuinfo[i - 1][0] = savemenufilescanner.nextline();                 savemenufilescanner.nextline();                 savemenufilescanner.nextline();                 savemenufilescanner.nextline();                 savemenuinfo[i - 1][1] = savemenufilescanner.nextline();                 savemenuinfo[i - 1][2] = savemenufilescanner.nextline();             } catch (filenotfoundexception ex) {                 logger.getlogger(jrpg.class.getname()).log(level.severe, null, ex);             }         } else {             savemenuinfo[i - 1][0] = null;         }     }... 

and running/compiling using method netbeans make application/game in "e:\copy\jrpg\build\classes\jrpg\saves."

when clean , build project, , try run via command line response this:

jar:file:/c:/users/adam/desktop/new%20folder/jrpg.jar!/jrpg/saves/save1.txt 

aug 22, 2013 11:54:18 pm jrpg.jrpg savesmanagementmenu severe: null java.io.filenotfoundexception: file:\c:\users\adam\desktop\new%20folder\jrpg.jar !\jrpg\saves\save1.txt (the filename, directory name, or volume label syntax incorrect)

and game freezes up. file path saves want when run compiled code is: c:\users\adam\desktop\new folder\saves

which relative file path right? how can fix problem compiled code looks in correct location no matter run file from? (lets friend wanted run game computer except put "new folder" folder somwhere other desktop)

a embedded resource not file , can't treated one. also, far output files, shouldn't trying save inside application anyway...

instead, either save file relative location of application...

file savemenusavefile = new file("./saves/save" + + ".txt"); 

or users home directory...

string userhome = system.getproperty("user.home"); file savemenusavefile = new file(userhome + "/.youapplicationname/saves/save" + + ".txt");