Here you can find the source of getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)
public static File getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative) throws IOException
//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(); } } }