Here you can find the source of getCanonicalPath(String inPath)
public static String getCanonicalPath(String inPath)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { public static String getCanonicalPath(String inPath) { return isBlank(inPath) ? inPath : getCanonicalFile(inPath, false).getAbsolutePath(); }/*from w w w .jav a2 s. c o m*/ public static boolean isBlank(String inValue) { return inValue == null || inValue.trim().isEmpty(); } public static File getCanonicalFile(String inPath) { return getCanonicalFile(inPath, false); } public static File getCanonicalFile(String inPath, boolean inThrowRuntimeException) { return isBlank(inPath) ? null : getCanonicalFile(new File(inPath), inThrowRuntimeException); } /** * Will return absolute file if not possible to determine the canonical file. * * Same as <code>getCanonicalFile(File inFile, boolean inThrowRuntimeException)</code> but parameter <code>inThrowRuntimeException</code> is set to <code>false</code> * @param inFile * @return */ public static File getCanonicalFile(File inFile) { return getCanonicalFile(inFile, false); } public static File getCanonicalFile(File inFile, boolean inThrowRuntimeException) { try { return inFile == null ? null : inFile.getCanonicalFile(); } catch (final IOException e) { if (inThrowRuntimeException) { throw new RuntimeException(inFile == null ? "File is null" : e.getMessage(), e); } return inFile.getAbsoluteFile(); } } }