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 path)
get Canonical Path
String canonPath;
try {
    canonPath = new File(path).getCanonicalPath();
} catch (IOException e) {
    canonPath = path;
return canonPath;
StringgetCanonicalPath(String s)
Get the canonical path from string Added by JG 2016
File f = new File(s);
try {
    s = f.getCanonicalPath();
} catch (IOException ex) {
    System.out.println("Get Canonical Path Failed!");
    System.out.println(ex);
    ex.printStackTrace();
return s;
StringgetCanonicalPathIfPossible(java.io.File file)
get Canonical Path If Possible
if (file != null) {
    try {
        return file.getCanonicalPath();
    } catch (java.io.IOException ioe) {
        return file.getAbsolutePath();
} else {
    return null;
...
FilegetCanonicalPathQuietly(String inPath)
get Canonical Path Quietly
return getCanonicalPathQuietly(inPath, false);
ListgetCanonicalPaths(List filenames)
get Canonical Paths
List result = new ArrayList();
for (int i = 0; i < filenames.size(); i++) {
    File file = new File((String) filenames.get(i));
    result.add(file.getCanonicalPath());
return result;
StringgetCanonicalPathWithoutFilename(String filename)
get Canonical Path Without Filename
final File file = new File(filename);
String string = null;
try {
    string = file.getCanonicalPath().substring(0, file.getCanonicalPath().indexOf(file.getName()));
} catch (final IOException e) {
    e.printStackTrace();
return string;
...
StringgetCanonicalSubPath(File inBasepathDir, File inFile)
get Canonical Sub Path
return getCanonicalSubPath(inBasepathDir, inFile, false);