List of usage examples for java.io File isAbsolute
public boolean isAbsolute()
From source file:org.globus.workspace.testing.NimbusTestBase.java
private static boolean okdir(File dir) { return dir.isAbsolute() && dir.exists() && dir.isDirectory(); }
From source file:com.meltmedia.cadmium.core.FileSystemManager.java
public static String[] getDirectoriesInDirectory(String directory, final String baseName) { File dir = new File(directory); if (dir.isDirectory()) { String files[] = null;//from www . j a v a 2s . c o m files = dir.list(new FilenameFilter() { @Override public boolean accept(File file, String name) { if (baseName != null && baseName.length() > 0) { return file.isDirectory() && file.isAbsolute() && name.startsWith(baseName); } return file.isDirectory(); } }); if (files != null) { return files; } } return new String[] {}; }
From source file:net.pms.newgui.StatusTab.java
public static BufferedImage getRendererIcon(String icon) { BufferedImage bi = null;//from w w w. ja v a2s . c o m if (icon != null) { if (icon.matches(".*\\S+://.*")) { try { bi = ImageIO.read(new URL(icon)); } catch (Exception e) { LOGGER.debug("Error reading icon url: " + e); } if (bi != null) { return bi; } else { LOGGER.debug("Unable to read icon url \"{}\", using '{}' instead.", RendererConfiguration.UNKNOWN_ICON); icon = RendererConfiguration.UNKNOWN_ICON; } } try { InputStream is = null; /** * Check for a custom icon file first * * The file can be a) the name of a file in the renderers directory b) a path relative * to the PMS working directory or c) an absolute path. If no file is found, * the built-in resource (if any) is used instead. * * The File constructor does the right thing for the relative and absolute path cases, * so we only need to detect the bare filename case. * * RendererIcon = foo.png // e.g. $PMS/renderers/foo.png * RendererIcon = images/foo.png // e.g. $PMS/images/foo.png * RendererIcon = /path/to/foo.png */ File f = new File(icon); if (!f.isAbsolute() && f.getParent() == null) { // filename f = new File("renderers", icon); } if (f.isFile()) { is = new FileInputStream(f); } if (is == null) { is = LooksFrame.class.getResourceAsStream("/resources/images/clients/" + icon); } if (is == null) { is = LooksFrame.class.getResourceAsStream("/renderers/" + icon); } if (is != null) { bi = ImageIO.read(is); } } catch (IOException e) { LOGGER.debug("Caught exception", e); } } if (bi == null) { LOGGER.debug("Failed to load icon: " + icon); } return bi; }
From source file:com.piketec.jenkins.plugins.tpt.Utils.java
/** * Builds a absolute path from the workspace directory and the given path. * <ul>//from w ww . j ava2 s .c o m * <li>If both are <code>null</code>, the current working directory will returned - hopefully it * is inside the workspace.</li> * <li>If the workspace is <code>null</code>, the path will returned.</li> * <li>If the path is <code>null</code>, the workspace will returned.</li> * <li>If the path is absolute, the path will returned.</li> * <li>If the path is relative, the path will append to the workspace and returned.</li> * </ul> * * @param workspaceDir * Current workspace for the build. * @param path * Relative or absolute path. * @return A absolute path, but it can be a nonexisting file system object or not a directory. */ public static File getAbsolutePath(File workspaceDir, File path) { File absPath = workspaceDir; if (path == null) { absPath = (workspaceDir == null) ? new File("") : workspaceDir; } else { if (path.isAbsolute()) { absPath = path; } else { absPath = (workspaceDir == null) ? path : new File(workspaceDir, path.toString()); } } return absPath.isAbsolute() ? absPath : absPath.getAbsoluteFile(); }
From source file:org.broadinstitute.gatk.utils.io.IOUtils.java
/** * Returns the sub path rooted at the parent. * * @param parent The parent directory.//from w w w . j a va 2 s.c o m * @param file The sub path to append to the parent, if the path is not absolute. * @return The absolute path to the file in the parent dir if the path was not absolute, otherwise the original path. */ public static File absolute(File parent, File file) { String newPath; if (file.isAbsolute()) newPath = absolutePath(file); else newPath = absolutePath(new File(parent, file.getPath())); return replacePath(file, newPath); }
From source file:org.apache.camel.util.FileUtil.java
/** * Is the given file an absolute file./*from w w w. j a va2s.c om*/ * <p/> * Will also work around issue on Windows to consider files on Windows starting with a \ * as absolute files. This makes the logic consistent across all OS platforms. * * @param file the file * @return <tt>true</ff> if its an absolute path, <tt>false</tt> otherwise. */ public static boolean isAbsolute(File file) { if (isWindows()) { // special for windows String path = file.getPath(); if (path.startsWith(File.separator)) { return true; } } return file.isAbsolute(); }
From source file:org.colombbus.tangara.FileUtils.java
public static File findFile(String fileName) { File file = new File(fileName); if (!file.isAbsolute()) { // the name does not contain any directory reference : add the current directory file = new File(Program.instance().getCurrentDirectory(), fileName); // if file does not exist, try with user home directory if (!file.exists()) file = new File(Configuration.instance().getUserHome(), fileName); fileName = file.getAbsolutePath(); }/*from w w w.j a v a 2 s . c o m*/ if (!(file.exists())) return null; else return file; }
From source file:com.eviware.soapui.support.Tools.java
public static String ensureDir(String dir, String basedir) { if (dir == null || dir.length() == 0) { return ""; }//from ww w.j ava 2 s . co m File dirFile = new File(dir); if (!dirFile.isAbsolute()) { if (basedir.length() == 0) { basedir = new File("").getAbsolutePath(); } dirFile = new File(basedir, dir); } dirFile.mkdirs(); return dirFile.getAbsolutePath(); }
From source file:com.hipu.bdb.util.FileUtils.java
/** * Turn path into a File, relative to context (which may be ignored * if path is absolute). // w w w .jav a 2s. co m * * @param context File context if path is relative * @param path String path to make into a File * @return File created */ public static File maybeRelative(File context, String path) { File f = new File(path); if (f.isAbsolute()) { return f; } return new File(context, path); }
From source file:com.eviware.soapui.support.Tools.java
public static String ensureFileDir(String file, String basedir) { if (file == null || file.length() == 0) { return ""; }// w w w. j ava2 s. c o m File dirFile = new File(basedir, file); if (!dirFile.isAbsolute()) { if (basedir.length() == 0) { basedir = new File("").getAbsolutePath(); } dirFile = new File(basedir, file); } String absolutePath = dirFile.getAbsolutePath(); if (!dirFile.exists()) { int ix = absolutePath.lastIndexOf(File.separatorChar); File fileDir = new File(absolutePath.substring(0, ix)); fileDir.mkdirs(); } return absolutePath; }