Java Path Relative nio getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)

Here you can find the source of getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)

Description

get File From Base File And Path That May Be Relative

License

Apache License

Declaration

public static File getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)
            throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

import java.nio.file.Paths;

public class Main {
    public static File getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)
            throws IOException {
        if (Paths.get(pathThatMayBeRelative).isAbsolute()) {
            return new File(pathThatMayBeRelative);
        } else {//www  . j a  v  a  2 s .  c om
            return Paths.get(baseDir.getAbsolutePath(), pathThatMayBeRelative).toFile().getCanonicalFile();
        }
    }
}

Related

  1. checkNormalizedRelative(String path)
  2. combinePaths(String baseDir, String relativePath)
  3. get(File basePath, String... relatives)
  4. getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath)
  5. getFileRelativeFolders(Path basePath, Path filePath)
  6. getOptionalPathRelativeToMavenProjectRoot(File absoluteFile)
  7. getRelativeFilePathToCwd(File file)
  8. getRelativePath(File baseFile, File file, String resultIfImpossible)