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

StringgetCanonicalOrAbsolutePath(File file)
Provides the canonical path of a file, or its absolute path, if it's not possible to provide the canonical path.
try {
    return file.getCanonicalPath();
} catch (IOException ioe) {
    return file.getAbsolutePath();
StringgetCanonicalPath(File file)
Returns the canonical path to a directory
String canonicalPath = "";
try {
    canonicalPath = file.getCanonicalPath();
} catch (IOException ignored) {
return canonicalPath;
StringgetCanonicalPath(File inFile, boolean inThrowRuntimeException)
get Canonical Path
try {
    return inFile.getCanonicalPath();
} catch (final IOException e) {
    if (inThrowRuntimeException) {
        throw new RuntimeException(inFile == null ? "File is null" : e.getMessage(), e);
    return null;
StringgetCanonicalPath(final File file)
Get file canonical path in privileged mode.
try {
    return file.getCanonicalPath();
} catch (IOException pae) {
    throw new IOException();
} catch (RuntimeException pae) {
    throw new RuntimeException();
StringgetCanonicalPath(final File file)
get Canonical Path
try {
    return file.getCanonicalPath();
} catch (final IOException e) {
    return file.getAbsolutePath();
StringgetCanonicalPath(final String path)
get Canonical Path
try {
    return (new File(path)).getCanonicalPath();
} catch (Throwable ignored) {
    return path;
IPathgetCanonicalPath(IPath fullPath)
Return the canonical path (or the passed in path, if one couldn't be found).
if (!fullPath.isAbsolute())
    return fullPath;
File file = fullPath.toFile();
try {
    String canonPath = file.getCanonicalPath();
    IPath canonicalPath = new Path(canonPath);
    if (fullPath.getDevice() == null)
        canonicalPath = canonicalPath.setDevice(null);
...
IPathgetCanonicalPath(IPath fullPath)
get Canonical Path
File file = fullPath.toFile();
try {
    String canonPath = file.getCanonicalPath();
    return new Path(canonPath);
} catch (IOException ex) {
return null;
StringgetCanonicalPath(String basePath, String path)
Get the canonical path from the basePath and relative path.
File found = null;
if (!(new File(path).isAbsolute())) {
    found = new File(basePath, path);
} else {
    found = new File(path);
return found.getCanonicalPath();
StringgetCanonicalPath(String filePath, String prefix)
get Canonical Path
if (prefix == null || filePath.equals(prefix) || !filePath.startsWith(prefix)) {
    return filePath;
int startIndex = prefix.length();
if (filePath.charAt(startIndex) == File.separatorChar) {
    startIndex++;
return filePath.substring(startIndex);
...