Here you can find the source of getCanonicalFile(File file)
public static final File getCanonicalFile(File file)
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { public static final File getCanonicalFile(File file) { if (file == null) throw new IllegalArgumentException("file must not be null."); try {//from ww w .ja v a2 s .co m return (file.getCanonicalFile()); } catch (IOException e) { return (file.getAbsoluteFile()); } } /** * Returns the canonical representation of the given file using {@link File#getCanonicalFile()}. * If this fails, the result of {@link File#getAbsoluteFile()} is returned. * * @param filename * * @return the canonical representation of the given file. */ public static final File getCanonicalFile(String filename) { return (getCanonicalFile(new File(filename))); } }