Location to store save files on local machine in java
<p>I have made a java applet/application game that should save levels that the user can create to their local machine.
I say applet/application because it can run either as an application or as an applet.
Currently I am using this to write the file:</p>

<pre><code>BufferedWriter bf = new BufferedWriter(new FileWriter("Circles/levels/level.txt"));
for (int i = 0; i &lt; lines.size(); i++) {
    bf.write(lines.get(i));
    bf.newLine();
}
</code></pre>

<p>lines is an arraylist with the lines to write to the file.</p>

<p>and </p>

<pre><code>FileReader fr = new FileReader("Circles/levels/level.txt");
        BufferedReader bf = new BufferedReader(fr);
        lines = new ArrayList&lt;String&gt;();
        while (true) {
            String line = bf.readLine();
            if (line == null) {
                break;
            }
            lines.add(line);
        }
        bf.close();
</code></pre>

<p>to read the file. Those are surrounded in try/catch loops, I am just showing what I have to.</p>

<p>This works ok, but it seems to be a completely different location on different operating systems, and the application stores in a different location as the applet.</p>

<p>I would like a way to get an absolute path to a place to save levels that would not change no matter where the java program is being run from, and would be the same if you ran it as an application and as an applet. Also it would be nice to have this work on all operating systems (linux, windows, mac).</p>
