Java os path operations, joins, and moving up levels
<p>I have 2 related questions regarding files, and the File class in Java.</p>

<p>I gather the best practice way to build a path - and have it OS agnostic - is like this:</p>

<pre><code>File file = new File("dir" + File.separator + "filename.ext");
</code></pre>

<p>My first question is, "Is there a Java equivalent of python os.path.join function built into Java?"
i.e. Is there a function where I can do something like this:</p>

<pre><code>String path = some_func("arbitrary", "number", "of", "subdirs", "filename.ext");
</code></pre>

<p>I suspect if such a thing exists, I may need to pass an Array of Strings to the function, rather than an arbitrary number of args, but the above would be ideal.</p>

<p>But regardless of the answer to the question above, my second question is, "is there a built in way to move a level up when specifying a path?"</p>

<p>i.e. Is the correct way, to do something like this:</p>

<pre><code>String rel_path = ".." + File.separator + "filename.ext";
</code></pre>

<p>Or is there something like this:</p>

<pre><code>String rel_path = File.level_up + File.separator + "filename.ext";
</code></pre>

<p>Cheers all!</p>
