List of usage examples for java.io File isAbsolute
public boolean isAbsolute()
From source file:generator.Utils.java
public static File makeAbsolute(String path) { File file = new File(path); if (!file.isAbsolute()) { return join(System.getProperty("user.home", "."), path); }//from w ww . j a v a2 s. co m return file; }
From source file:Main.java
/** Convert a file path into a File object with an absolute path relative to a passed in root. If path is absolute then a file object constructed from new File(path) is returned, otherwise a file object is returned from new File(root, path) if root is not null, otherwise null is returned. *///from w w w . ja va2s . c om public static File getAbsoluteFile(File root, String path) { File file = new File(path); if (file.isAbsolute()) return file; if (root == null) return null; return new File(root, path); }
From source file:com.mirth.connect.util.FilenameUtils.java
public static String getAbsolutePath(File baseDir, String path) { path = StringUtils.trim(path);//from ww w. ja v a2 s. co m File file = new File(path); if (file.isAbsolute()) { return file.getPath(); } char firstChar = path.charAt(0); /* * For Windows systems, if the path begins with a forward or back slash, extract the drive * letter from baseDir and use the drive's root directory as the new baseDir. */ if (firstChar == '/' || firstChar == '\\') { File parent = baseDir.getParentFile(); while (parent != null) { baseDir = parent; parent = baseDir.getParentFile(); } return new File(baseDir, path).getAbsolutePath(); } return new File(baseDir, path).getAbsolutePath(); }
From source file:org.apache.openejb.resource.jdbc.HsqldbDataSourcePlugin.java
public static String toAbsolutePath(String url) { // is this a hsql file url? if (url == null || !url.startsWith(HSQL_FILE_URL)) { return url; }// w w w .ja va 2 s.c o m // get the relative path String path = url.substring(HSQL_FILE_URL.length()); // make an absolute file File file = new File(path); if (!file.isAbsolute()) { File base = SystemInstance.get().getBase().getDirectory(); file = new File(base, path); } // make an absolute url path = file.getAbsolutePath(); return HSQL_FILE_URL + path; }
From source file:AIR.Common.Utilities.Path.java
public static boolean isAbsolute(String path) { File f = new File(path); return f.exists() && f.isAbsolute(); }
From source file:io.github.kitarek.elasthttpd.plugins.consumers.file.mapper.UriToFileMapper.java
private static boolean isValidExistingAbsoluteDirectory(File f) { return f.canRead() && f.exists() && f.isAbsolute() && f.isDirectory(); }
From source file:org.gradle.api.internal.externalresource.transport.file.FileResourceConnector.java
private static File getFile(String absolutePath) { File f = new File(absolutePath); if (!f.isAbsolute()) { throw new IllegalArgumentException("Filename must be absolute: " + absolutePath); }// ww w . jav a 2 s . co m return f; }
From source file:dtool.dub.BundlePath.java
/*** * Searches for a manifest file in any of the directories denoted by given path, starting in path. *///from w w w . ja v a2 s. c o m public static BundlePath findBundleForPath(File path) { if (path == null || !path.isAbsolute()) { return null; } BundlePath bundleFile = create(path); if (bundleFile != null && bundleFile.getManifestFilePath().exists()) { return bundleFile; } return findBundleForPath(path.getParentFile()); }
From source file:dtool.dub.BundlePath.java
public static boolean isValidBundlePath(File path) { assertNotNull(path);/*from w w w .ja va 2s. c o m*/ return path.isAbsolute() && FileUtil.getNameCount(path) > 0; }
From source file:org.apache.solr.util.FileUtils.java
/** * Resolves a path relative a base directory. * * <p>//from w w w . ja v a 2 s. co m * This method does what "new File(base,path)" <b>Should</b> do, if it wasn't * completely lame: If path is absolute, then a File for that path is returned; * if it's not absolute, then a File is returned using "path" as a child * of "base") * </p> */ public static File resolvePath(File base, String path) { File r = new File(path); return r.isAbsolute() ? r : new File(base, path); }