Example usage for java.io File isAbsolute

List of usage examples for java.io File isAbsolute

Introduction

In this page you can find the example usage for java.io File isAbsolute.

Prototype

public boolean isAbsolute() 

Source Link

Document

Tests whether this abstract pathname is absolute.

Usage

From source file:com.servoy.extension.install.LibActivationHandler.java

protected File getRelativePluginFile(String relativePluginPath) {
    File f = new File(relativePluginPath);
    if (!f.isAbsolute()) {
        f = new File(pluginsDir, relativePluginPath);
    }/*from  w w  w .  j a v  a  2 s . c  o  m*/
    return f;
}

From source file:org.archive.crawler.framework.Engine.java

/**
 * Copy a job to a new location, possibly making a job
 * a profile or a profile a runnable job. 
 * /*from www  . j a v  a  2  s  . c  o  m*/
 * @param cj CrawlJob representing source
 * @param copyTo String location destination; interpreted relative to jobsDir
 * @param asProfile true if destination should become a profile
 * @throws IOException 
 */
public void copy(CrawlJob cj, String copyTo, boolean asProfile) throws IOException {
    File dest = new File(copyTo);
    if (!dest.isAbsolute()) {
        dest = new File(jobsDir, copyTo);
    }
    copy(cj, dest, asProfile);
}

From source file:au.org.ala.delta.io.OutputFileManager.java

public String makeAbsolute(String fileName) {
    File file = new File(fileName);
    if (!file.isAbsolute()) {
        File workingDir = _context.getFile().getParentFile();
        file = new File(workingDir, fileName);
    }/*w  w  w.  j  a  v  a2s. com*/
    return file.getAbsolutePath();
}

From source file:com.textocat.textokit.commons.consumer.XmiWriter.java

/**
 * Processes the CAS which was populated by the TextAnalysisEngines. <br>
 * In this case, the CAS is converted to XMI and written into the output
 * file .//from  ww  w.ja v a  2  s  . c  om
 *
 * @param aCAS a CAS which has been populated by the TAEs
 * @see org.apache.uima.collection.base_cpm.CasObjectProcessor#processCas(org.apache.uima.cas.CAS)
 */
public void process(CAS aCAS) throws AnalysisEngineProcessException {
    JCas jcas;
    try {
        jcas = aCAS.getJCas();
    } catch (CASException e) {
        throw new AnalysisEngineProcessException(e);
    }

    // retrieve the filename of the input file from the CAS
    FSIterator<Annotation> it = jcas.getAnnotationIndex(DocumentMetadata.type).iterator();
    File outFile = null;
    if (it.hasNext()) {
        DocumentMetadata meta = (DocumentMetadata) it.next();
        File inFile;
        try {
            inFile = new File(new URL(meta.getSourceUri()).getPath());
            String outFileName;
            if (writeToRelativePath) {
                if (inFile.isAbsolute()) {
                    throw new IllegalStateException(String.format(
                            "Source URI contains absolute path %s and writeToRelativePath is set to TRUE",
                            meta.getSourceUri()));
                }
                outFileName = inFile.getPath();
            } else {
                outFileName = inFile.getName();
            }
            if (meta.getOffsetInSource() > 0) {
                outFileName += ("_" + meta.getOffsetInSource());
            }
            outFileName += ".xmi";
            outFile = new File(mOutputDir, outFileName);
        } catch (MalformedURLException e1) {
            // invalid URL, use default processing below
        }
    }
    if (outFile == null) {
        outFile = new File(mOutputDir, "doc" + mDocNum++ + ".xmi"); // Jira UIMA-629
    }
    // serialize XCAS and write to output file
    try {
        writeXmi(jcas.getCas(), outFile);
    } catch (IOException e) {
        throw new AnalysisEngineProcessException(e);
    } catch (SAXException e) {
        throw new AnalysisEngineProcessException(e);
    }
}

From source file:au.org.ala.delta.io.OutputFileManager.java

protected File createFile(String fileName) {

    File parent = null;/*from w  w  w .j  av a 2 s  .  c  o m*/

    if (_context.getFile() != null) {
        parent = _context.getFile().getParentFile();
    }

    if (parent == null) {
        parent = new File(System.getProperty("user.dir"));
    }

    File file = new File(fileName);
    if (!file.isAbsolute()) {
        file = new File(FilenameUtils.concat(parent.getAbsolutePath(), fileName));
    }
    return file;
}

From source file:edu.stolaf.cs.wmrserver.TransformProcessor.java

private File getLibraryDirectory(SubnodeConfiguration languageConf) {
    String libDirString = languageConf.getString("library", "");
    if (libDirString.isEmpty())
        return null;
    File libDir = new File(libDirString);
    if (!libDir.isAbsolute())
        libDir = new File(m_languageConfDir, libDirString);
    return libDir;
}

From source file:com.npower.dm.setup.task.DMTask.java

/**
 * Load ManufacturerItems from DM setup data files.
 * @param filename/*from   www .  ja  v a2  s . c o m*/
 * @return
 */
protected List<ManufacturerItem> loadManufacturerItems(String filename) throws SetupException {
    List<ManufacturerItem> result = new ArrayList<ManufacturerItem>();
    try {
        Digester digester = this.createManufacturerDigester();
        digester.push(result);
        digester.parse(new FileInputStream(filename));

        for (ManufacturerItem item : result) {
            List<String> includeFilenames4Model = item.getIncludedFiles4Models();
            for (String includeFilename : includeFilenames4Model) {
                digester.push(item);
                File file = new File(includeFilename);
                if (!file.isAbsolute()) {
                    file = new File(this.getSetup().getWorkDir(), includeFilename);
                }
                // Trace definition file
                item.setCurrentModelDefinitionFilename(file.getAbsolutePath());

                digester.parse(new FileInputStream(file));
            }
        }

        return result;
    } catch (Exception e) {
        throw new SetupException(e);
    }
}

From source file:de.jflex.plugin.maven.JFlexMojo.java

/**
 * Generate java code of a parser from a lexer file.
 * //from ww w .  j a  va 2s. co  m
 * If the {@code lexDefinition} is a directory, process all lexer files
 * contained within.
 * 
 * @param lexDefinition
 *            Lexer definiton file or directory to process.
 * @throws MojoFailureException
 *             if the file is not found.
 * @throws MojoExecutionException
 */
@SuppressWarnings("unchecked")
private void parseLexDefinition(File lexDefinition) throws MojoFailureException, MojoExecutionException {
    assert lexDefinition.isAbsolute() : lexDefinition;

    if (lexDefinition.isDirectory()) {
        // recursively process files contained within
        String[] extensions = { "jflex", "jlex", "lex", "flex" };
        getLog().debug("Processing lexer files found in " + lexDefinition);
        Iterator<File> fileIterator = FileUtils.iterateFiles(lexDefinition, extensions, true);
        while (fileIterator.hasNext()) {
            File lexFile = fileIterator.next();
            parseLexFile(lexFile);
        }
    } else {
        parseLexFile(lexDefinition);
    }
}

From source file:com.enjoyxstudy.selenium.htmlsuite.HTMLSuiteLauncher.java

/**
 * Launches a single HTML Selenium test suite.
 *
 * @param browser - the browserString ("*firefox", "*iexplore" or an executable path)
 * @param browserURL - the start URL for the browser
 * @param suiteFile - a file containing the HTML suite to run
 * @param resultFile - The file to which we'll output the HTML results
 * @param timeoutInSeconds - the amount of time (in seconds) to wait for the browser to finish
 * @param multiWindow//w  ww.  j a  v a  2s. co m
 * @return result
 * @throws IOException if we can't read the write file
 */
public boolean runHTMLSuiteResult(String browser, String browserURL, File suiteFile, File resultFile,
        long timeoutInSeconds, boolean multiWindow) throws IOException {

    log.info("HTML Suite Start. suite[" + suiteFile + "] browser[" + browser + "]");

    processResults(null); // init result

    if (!suiteFile.isAbsolute()) {
        suiteFile = suiteFile.getAbsoluteFile();
    }

    boolean isResultTemprary = false;
    if (resultFile == null) {
        resultFile = File.createTempFile(TEMP_RESULT_FILE_PREFIX, null);
        isResultTemprary = true;
    }

    String resultString;
    try {
        resultString = runHTMLSuite(browser, browserURL, suiteFile, resultFile, timeoutInSeconds, multiWindow);
    } finally {
        if (isResultTemprary) {
            resultFile.delete();
        }
    }

    boolean result = resultString.equals(RESULT_PASSED);

    String endMessage = "HTML Suite End. result[" + resultString + "] suite[" + suiteFile + "] browser["
            + browser + "]";

    if (result) {
        log.info(endMessage);
    } else {
        log.warn(endMessage);
    }
    return result;
}

From source file:com.webcohesion.enunciate.EnunciateConfiguration.java

public File resolveFile(String filePath) {
    if (File.separatorChar != '/') {
        filePath = filePath.replace('/', File.separatorChar); //normalize on the forward slash...
    }//w ww.j  av a  2s.co  m

    File downloadFile = new File(filePath);

    if (!downloadFile.isAbsolute()) {
        //try to relativize this file to the directory of the config file.
        File base = this.base;
        if (base == null) {
            File configFile = getSource().getFile();
            if (configFile != null) {
                base = configFile.getAbsoluteFile().getParentFile();
            }
        }

        if (base != null) {
            downloadFile = new File(base, filePath);
        }
    }
    return downloadFile;
}