List of usage examples for java.io File isAbsolute
public boolean isAbsolute()
From source file:br.msf.commons.util.IOUtils.java
public static boolean isAbsolute(final File file) { return file != null && file.isAbsolute(); }
From source file:br.msf.commons.util.IOUtils.java
public static boolean isNotAbsolute(final File file) { return file == null || !file.isAbsolute(); }
From source file:com.lenovo.tensorhusky.common.utils.Shell.java
private static String checkTensorHuskyLogDir() { // first check the Dflag hadoop.home.dir with JVM scope String home = System.getProperty("tensorhusky.log.dir"); // fall back to the system/user-global env variable if (home == null) { home = System.getenv("TENSORHUSKY_LOG_DIR"); }/*from ww w. j a va2 s. co m*/ try { // couldn't find either setting for hadoop's home directory if (home == null) { throw new IOException("TENSORHUSKY_LOG_DIR or tensorhusky.log.dir are not set."); } if (home.startsWith("\"") && home.endsWith("\"")) { home = home.substring(1, home.length() - 1); } // check that the home setting is actually a directory that exists File homedir = new File(home); if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) { throw new IOException("Tensorhusky log directory " + homedir + " does not exist, is not a directory, or is not an absolute path."); } home = homedir.getCanonicalPath(); } catch (IOException ioe) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to detect a valid Tensorhusky home directory", ioe); } home = null; } return home; }
From source file:com.lenovo.tensorhusky.common.utils.Shell.java
private static String checkTensorHuskyWorkDir() { // first check the Dflag hadoop.home.dir with JVM scope String home = System.getProperty("tensorhusky.work.dir"); // fall back to the system/user-global env variable if (home == null) { home = System.getenv("TENSORHUSKY_WORK_DIR"); }/*from www . ja va 2s . c om*/ try { // couldn't find either setting for hadoop's home directory if (home == null) { throw new IOException("TENSORHUSKY_WORK_DIR or tensorhusky.work.dir are not set."); } if (home.startsWith("\"") && home.endsWith("\"")) { home = home.substring(1, home.length() - 1); } // check that the home setting is actually a directory that exists File homedir = new File(home); if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) { throw new IOException("Tensorhusky log directory " + homedir + " does not exist, is not a directory, or is not an absolute path."); } home = homedir.getCanonicalPath(); } catch (IOException ioe) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to detect a valid Tensorhusky home directory", ioe); } home = null; } return home; }
From source file:com.lenovo.tensorhusky.common.utils.Shell.java
private static String checkTensorHuskyHome() { // first check the Dflag hadoop.home.dir with JVM scope String home = System.getProperty("tensorhusky.home.dir"); // fall back to the system/user-global env variable if (home == null) { home = System.getenv("TENSORHUSKY_HOME"); }/*w w w .jav a 2s .c o m*/ try { // couldn't find either setting for hadoop's home directory if (home == null) { throw new IOException("TENSORHUSKY_HOME or tensorhusky.home.dir are not set."); } if (home.startsWith("\"") && home.endsWith("\"")) { home = home.substring(1, home.length() - 1); } // check that the home setting is actually a directory that exists File homedir = new File(home); if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) { throw new IOException("Tensorhusky home directory " + homedir + " does not exist, is not a directory, or is not an absolute path."); } home = homedir.getCanonicalPath(); } catch (IOException ioe) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to detect a valid Tensorhusky home directory", ioe); } home = null; } return home; }
From source file:com.lenovo.tensorhusky.common.utils.Shell.java
/** * check SparkHome/*from w w w. j a v a 2s . co m*/ * * @return sparkHomeDir */ private static String checkSparkHome() { // first check the Dflag hadoop.home.dir with JVM scope String home = System.getProperty("spark.home.dir"); // fall back to the system/user-global env variable if (home == null) { home = System.getenv("SPARK_HOME"); } try { // couldn't find either setting for hadoop's home directory if (home == null) { throw new IOException("SPARK_HOME or spark.home.dir are not set."); } if (home.startsWith("\"") && home.endsWith("\"")) { home = home.substring(1, home.length() - 1); } // check that the home setting is actually a directory that exists File homedir = new File(home); if (!homedir.isAbsolute() || !homedir.exists() || !homedir.isDirectory()) { throw new IOException("Spark home directory " + homedir + " does not exist, is not a directory, or is not an absolute path."); } home = homedir.getCanonicalPath(); } catch (IOException ioe) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to detect a valid spark home directory", ioe); } home = null; } return home; }
From source file:org.eobjects.datacleaner.user.DataCleanerConfigurationReaderInterceptor.java
@Override public String createFilename(String filename) { if (filename == null) { return null; }/* ww w .j a v a2 s . co m*/ final File file = new File(filename); if (file.isAbsolute()) { return filename; } try { FileObject fileObject = _dataCleanerHome.resolveFile(filename); return fileObject.getName().getPathDecoded(); } catch (FileSystemException e) { logger.warn("Could not resolve absolute path using VFS: " + filename, e); return filename; } }
From source file:de.ailis.xadrian.frames.MainFrame.java
/** * Opens the specified files. If the main frame is already started then the * files are opened right away. Otherwise the file names are queued for * later processing./* ww w . ja v a 2s .com*/ * * @param directory * The directory from which to open the files. Needed to resolve * relative file names. * @param fileNames * The names of the files to open. */ public static void open(final File directory, final String... fileNames) { synchronized (unprocessedFiles) { for (final String fileName : fileNames) { File file = new File(fileName); if (!file.isAbsolute()) file = new File(directory, fileName); if (instance == null) unprocessedFiles.add(file); else instance.open(file); } } // If main frame is already open then do lot of stuff to try to get // it into the foreground. if (instance != null) { instance.setExtendedState(Frame.NORMAL); instance.toFront(); instance.requestFocus(); instance.setVisible(true); } }
From source file:org.apache.openejb.server.httpd.part.CommonsFileUploadPart.java
@Override public void write(final String fileName) throws IOException { File file = new File(fileName); if (!file.isAbsolute()) { file = new File(location, fileName); }/* w w w . j av a 2 s .c om*/ try { fileItem.write(file); } catch (Exception e) { throw new IOException(e); } }
From source file:com.npower.dm.setup.task.TacTask.java
protected void processModelTacInformation() throws SetupException { List<String> filenames = this.getFilenames(); ManagementBeanFactory factory = null; try {/*from w ww . j a v a2 s . c o m*/ factory = this.getManagementBeanFactory(); // Import Profile Mappings for (String filename : filenames) { // Process the file, and import data into database. File file = new File(filename); if (!file.isAbsolute()) { file = new File(this.getSetup().getWorkDir(), filename); } this.getSetup().getConsole().println(" Loading file [ " + file.getAbsolutePath() + " ]"); TacImporter importer = new TacImporter(file, factory); importer.process(); } } catch (Exception ex) { throw new SetupException("Error in import TAC database.", ex); } finally { if (factory != null) { factory.release(); } } }