Java Canonical Path Create getCanonicalFile(File file)

Here you can find the source of getCanonicalFile(File file)

Description

get Canonical File

License

GNU General Public License

Declaration

public static File getCanonicalFile(File file) 

Method Source Code

//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;
    }
}

Related

  1. getCanonicalDirectory(final String rawDir)
  2. getCanonicalDirectory(String path, String errPrefix)
  3. getCanonicalFile(@Nullable final File aFile)
  4. getCanonicalFile(File f)
  5. getCanonicalFile(File file)
  6. getCanonicalFile(File file)
  7. getCanonicalFile(File file)
  8. getCanonicalFile(File inFile)
  9. getCanonicalFile(final File file)