I'd like to know how I can get the directory where the scenario (or .jar file) itself is saved on my computer so I can save files there. An no, it doesn't have to run on the greenfoot site or the browser.


1 2 | java.io.File file = new java.io.File( "filename.txt" ); // referenced as in 'jar' file if (!file.exists()) file = new java.io.File( "../filename.txt" ); // referenced as in greenfoot application |
1 | import java.io.File; |
1 2 | File file = new File( "filename.txt" ); if (!file.exists()) file = new File( "../filename.txt" ); |