Here you can find the source of getCanonicalFile(File file)
public static File getCanonicalFile(File file)
//package com.java2s; /* This code is part of Freenet. It is distributed under the GNU General * Public License, version 2 (or at your option any later version). See * http://www.gnu.org/ for further details of the GPL. */ import java.io.File; import java.io.IOException; public class Main { public static File getCanonicalFile(File file) { // Having some problems storing File's in db4o ... // It would start up, and canonicalise a file with path "/var/lib/freenet-experimental/persistent-temp-24374" // to /var/lib/freenet-experimental/var/lib/freenet-experimental/persistent-temp-24374 // (where /var/lib/freenet-experimental is the current working dir) // Regenerating from path worked. So do that here. // And yes, it's voodoo. file = new File(file.getPath()); File result;//from w w w . j a va2 s.co m try { result = file.getAbsoluteFile().getCanonicalFile(); } catch (IOException e) { result = file.getAbsoluteFile(); } return result; } }