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

StringgetCanonicalPath(String inPath)
get Canonical Path
return isBlank(inPath) ? inPath : getCanonicalFile(inPath, false).getAbsolutePath();
StringgetCanonicalPath(String name)
get Canonical Path
if (name == null)
    return null;
File f = new File(name);
try {
    return f.getCanonicalPath();
} catch (IOException ioe) {
    ioe.printStackTrace();
    return name; 
...
StringgetCanonicalPath(String outputPath)
get Canonical Path
final File file = new File(outputPath);
String path = null;
try {
    path = file.getCanonicalPath();
} catch (final IOException e) {
    e.printStackTrace();
return path;
...
StringgetCanonicalPath(String path)
Returns canonical file path for the given file path
return new File(path).getCanonicalPath();
StringgetCanonicalPath(String path)
get Canonical Path
File f = openFile(path);
return (f == null) ? null : getCanonicalPath(f);
StringgetCanonicalPath(String path)
Returns the canonical pathname string of given pathname.
try {
    return new File(path).getCanonicalPath();
} catch (IOException e) {
    return path;
StringgetCanonicalPath(String path)
Returns the absolute canonical path to the file/dir of the path passed in.
File f = new File(path);
try {
    return (f.getCanonicalPath());
} catch (Exception e) {
    return (path);
StringgetCanonicalPath(String path)
get Canonical Path
assert null != path && !path.isEmpty();
try {
    String canonicalPath = new File(path).getCanonicalPath();
    if (path.endsWith(File.separator)) {
        canonicalPath = canonicalPath + File.separator;
    return canonicalPath.contains(" ") ? String.format("\"%s\"", canonicalPath) : canonicalPath;
} catch (IOException e) {
...
StringgetCanonicalPath(String path)
Canonicalize the specified file path according to the current platform's rules:
  • Condense multiple consecutive path separators into a single path separator.
  • Remove "."
    File file = new File(path);
    if (isUnix()) {
        file = new File(file.toURI().normalize()).getAbsoluteFile();
    } else {
        try {
            file = file.getCanonicalFile();
        } catch (IOException e) {
            file = new File(file.toURI().normalize()).getAbsoluteFile();
    ...
    
StringgetCanonicalPath(String path)
get Canonical Path
String result = null;
try {
    result = new File(path).getCanonicalPath();
} catch (IOException e) {
    throw new RuntimeException("get Canonical path exception", e);
return result;