Java Canonical Path Create getCanonicalPathQuietly(String inPath)

Here you can find the source of getCanonicalPathQuietly(String inPath)

Description

get Canonical Path Quietly

License

Open Source License

Declaration

public static File getCanonicalPathQuietly(String inPath) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static File getCanonicalPathQuietly(String inPath) {

        return getCanonicalPathQuietly(inPath, false);
    }//from   w  w  w  .j a va  2 s.  c o  m

    public static File getCanonicalPathQuietly(String inPath, boolean inReturnAbsolutPathInstead) {

        return inPath == null ? null : getCanonicalPathQuietly(new File(inPath), inReturnAbsolutPathInstead);
    }

    public static File getCanonicalPathQuietly(File inFile) {
        return getCanonicalPathQuietly(inFile, false);
    }

    public static File getCanonicalPathQuietly(File inFile, boolean inReturnAbsolutPathInstead) {

        try {

            return inFile.getCanonicalFile();

        } catch (final Exception e) {

            try {

                return inReturnAbsolutPathInstead ? inFile.getAbsoluteFile() : null;

            } catch (final Exception e2) {
            }
        }

        return null;
    }
}

Related

  1. getCanonicalPath(String path)
  2. getCanonicalPath(String path)
  3. getCanonicalPath(String path)
  4. getCanonicalPath(String s)
  5. getCanonicalPathIfPossible(java.io.File file)
  6. getCanonicalPaths(List filenames)
  7. getCanonicalPathWithoutFilename(String filename)
  8. getCanonicalSubPath(File inBasepathDir, File inFile)