Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Concise version:</p> <ol> <li><code>File.getName()</code> returns the file name part as a string; i.e. the bit after the last file separator.</li> <li><code>File.getPath()</code> returns the complete pathname as a string.</li> <li><code>File.getAbsolutePath()</code> turns the complete pathname as a string, after mapping the path to an absolute path if it is currently relative. No attempt is made to validate the path.</li> <li><code>File.getAbsoluteFile()</code> does the same thing as <code>File.getAbsolutePath()</code>, except that the result is a <code>File</code>.</li> <li><code>File.getCanonicalPath()</code> maps the path to an absolute path (if it is currently relative) and then attempts to canonicalize it. This process is OS dependent, but it typically involves following symbolic links and replacing ".", ".." and empty names with their canonical equivalents. The result is the canonicalized path string.</li> <li><code>File.getCanonicalFile()</code> does the same as <code>File.getCanonicalPath()</code> except that its result is a <code>File</code>.</li> </ol> <p>The first 4 are really just text-based manipulations of the original <code>File</code> object. They make no attempt to check that any part of the path corresponds to anything in the file system.</p> <p>The last 2 involve checking the path to the last-named component of the <code>File</code>. If the path involves non-existent directories, broken links, directories than cannot be read and so on, you are liable to get an IOException.</p> <p>For more details, refer to the individual methods' javadocs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload