Java Canonical Path Create getCanonicalPath(String basePath, String path)

Here you can find the source of getCanonicalPath(String basePath, String path)

Description

Get the canonical path from the basePath and relative path.

License

Open Source License

Parameter

Parameter Description
basePath a parameter
path a parameter

Exception

Parameter Description
IOException an exception

Return

the canonical path from the "path".

Declaration

public static String getCanonicalPath(String basePath, String path) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.IOException;

public class Main {
    /**//from www .j  a  v a  2s  .c  om
     * Get the canonical path from the basePath and relative path.
     * 
     * @param basePath 
     * @param path
     * @return the canonical path from the "path".
     * @throws IOException
     */
    public static String getCanonicalPath(String basePath, String path) throws IOException {
        File found = null;
        if (!(new File(path).isAbsolute())) {
            found = new File(basePath, path);
        } else {
            found = new File(path);
        }
        return found.getCanonicalPath();
    }
}

Related

  1. getCanonicalPath(final File file)
  2. getCanonicalPath(final File file)
  3. getCanonicalPath(final String path)
  4. getCanonicalPath(IPath fullPath)
  5. getCanonicalPath(IPath fullPath)
  6. getCanonicalPath(String filePath, String prefix)
  7. getCanonicalPath(String inPath)
  8. getCanonicalPath(String name)
  9. getCanonicalPath(String outputPath)