Java Utililty Methods Canonical Path Create

List of utility methods to do Canonical Path Create

Description

The list of methods to do Canonical Path Create are organized into topic(s).

Method

FilegetCanonicalFile(File inFile)
Will return absolute file if not possible to determine the canonical file.
return getCanonicalFile(inFile, false);
FilegetCanonicalFile(final File file)
Gets the the canonical version of the abstract path.
return new File(file.getCanonicalPath());
FilegetCanonicalFile(final File file)
Returns the canonical file for the file without throwing a checked exception.
if (file == null) {
    return null;
try {
    return file.getCanonicalFile();
} catch (final IOException ex) {
    throw new RuntimeException("Couldn't get canonical file for: " + file, ex);
FilegetCanonicalFile(final File file)
Devuelve el fichero en su forma canónica.
try {
    return file.getCanonicalFile();
} catch (final IOException e) {
    LOGGER.severe("No se ha podido obtener el fichero canonico: " + e 
    );
    return file;
FilegetCanonicalFileEL(File file)
Returns the canonical form of this abstract pathname.
try {
    return file.getCanonicalFile();
} catch (IOException e) {
    return file;
StringgetCanonicalFileName(String filename)
get Canonical File Name
String canonicalFileName = filename;
try {
    canonicalFileName = new File(filename).getCanonicalPath();
} catch (IOException ignore) {
return canonicalFileName;
FilegetCanonicalFileOrNull(@Nullable final File aFile)
Get the canonical file of the passed file, if the file is not null.
try {
    return getCanonicalFile(aFile);
} catch (final IOException ex) {
    return null;
ListgetCanonicalFiles2List(List path, String[] allowedExtension)
get Canonical Files List
List<String> r = new ArrayList<String>();
for (String p : path) {
    List<String> r2 = new ArrayList<String>();
    File rfolder = new File(p);
    if (rfolder.exists() && rfolder.isDirectory()) {
        File[] files = rfolder.listFiles();
        for (File f : files) {
            if (f.isFile() && !f.getName().startsWith(".")) {
...
StringgetCanonicalFileURL(File file)
Solution for JVM bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6351751
String path = file.getAbsoluteFile().getPath();
if (File.separatorChar != '/') {
    path = path.replace(File.separatorChar, '/');
if (!path.startsWith("//")) {
    if (path.startsWith("/")) {
        path = "//" + path;
    } else {
...
StringgetCanonicalLocationFilePath(String location, String file)
get Canonical Location File Path
return new File(location, file).getCanonicalPath();