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:eu.asterics.mw.services.ResourceRegistry.java

/**
 * Resolves the given nonURIConformingFilePath to the given baseURI URI. The string may contain normal file path characters like space and supports \\ and / as seperators if parameter slashify=true 
 * @param baseURIPath/*from  w  w w. jav  a  2  s.c  o m*/
 * @param nonURIConformingFilePath
 * @param slashify true: Convert seperators to unix-style / 
 * @return
 */
public static File resolveRelativeFilePath(URI baseURIPath, String nonURIConformingFilePath, boolean slashify) {
    if (slashify) {
        nonURIConformingFilePath = FilenameUtils.separatorsToUnix(nonURIConformingFilePath);
    }
    //File resolvedFile=new File(new File(baseURI),nonURIConformingFilePath);
    //return resolvedFile;

    File absFile = new File(nonURIConformingFilePath);
    if (!absFile.isAbsolute()) {
        absFile = new File(new File(baseURIPath), nonURIConformingFilePath);
    }
    return absFile;

}

From source file:it.geosolutions.geobatch.flow.file.FileBasedFlowManager.java

public static File initTempDir(FileBasedFlowConfiguration flowConfiguration, File geoBatchTempDir)
        throws FileNotFoundException {

    File ret = null;

    File overrideTempDir = flowConfiguration.getOverrideTempDir();
    if (overrideTempDir != null) {
        ret = overrideTempDir;/*from  w w w . j ava 2  s  .c  o  m*/
        if (!ret.isAbsolute())
            throw new IllegalStateException(
                    "Override temp dir must be an absolute path (" + overrideTempDir + ")");
    } else {

        String flowId = flowConfiguration.getId();
        ret = new File(geoBatchTempDir, flowId);

        if (LOGGER.isDebugEnabled())
            LOGGER.debug("FlowBaseTempDir = " + ret);
    }

    if ((!ret.mkdir() && !ret.exists()) || !ret.canWrite())
        throw new IllegalStateException("Can't write temp dir (" + ret + ")");

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Flow: " + flowConfiguration.getId() + " - temp dir is now set to -> " + ret);
    }
    return ret;
}

From source file:com.facebook.config.ExpandedConfFileJSONProvider.java

@Override
protected String resolve(String parent, String config) {
    File file = new File(config);
    if (file.isAbsolute() || parent == null) {
        return file.getAbsolutePath();
    }//from  w  ww  .  j a  v  a 2  s.  co m

    // relative path
    File parentFile = new File(parent);
    file = new File(parentFile.getParent(), config);

    return file.getAbsolutePath();
}

From source file:org.apache.solr.core.CoreContainer.java

private static Properties getCoreProps(String instanceDir, String file, Properties defaults) {
    if (file == null)
        file = "conf" + File.separator + "solrcore.properties";
    File corePropsFile = new File(file);
    if (!corePropsFile.isAbsolute()) {
        corePropsFile = new File(instanceDir, file);
    }/*from w w w  .  ja  v  a2 s  .c  o m*/
    Properties p = defaults;
    if (corePropsFile.exists() && corePropsFile.isFile()) {
        p = new Properties(defaults);
        InputStream is = null;
        try {
            is = new FileInputStream(corePropsFile);
            p.load(is);
        } catch (IOException e) {
            log.warn("Error loading properties ", e);
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
    return p;
}

From source file:com.skcraft.launcher.creator.model.creator.Pack.java

@JsonIgnore
public File getDirectory() {
    File path = new File(location);
    if (path.isAbsolute()) {
        return path;
    } else {/*from   w  w  w .  j  a  va 2  s  .  c om*/
        return new File(workspace.getDirectory(), location);
    }
}

From source file:org.gradle.api.internal.file.BaseDirFileResolver.java

public BaseDirFileResolver(FileSystem fileSystem, File baseDir) {
    super(fileSystem);
    assert baseDir.isAbsolute() : String.format("base dir '%s' is not an absolute file.", baseDir);
    this.baseDir = baseDir;
}

From source file:org.gradle.api.internal.file.BaseDirConverter.java

@Override
protected File doResolve(Object path) {
    if (!GUtil.isTrue(path) || !GUtil.isTrue(baseDir)) {
        throw new IllegalArgumentException(String.format(
                "Neither path nor baseDir may be null or empty string. path='%s' basedir='%s'", path, baseDir));
    }/*from  w  w  w . j  a  v  a  2s  .c  om*/

    File file = convertObjectToFile(path);
    if (!file.isAbsolute()) {
        file = new File(baseDir, file.getPath());
    }

    return file;
}

From source file:com.nominum.build.LinkAssetsMojo.java

/** Convert Files with relative paths to be relative from the project basedir. **/
private File absolutePath(File file) {
    if (file.isAbsolute()) {
        return file;
    }/*from  www  .  j a v a  2 s . c  o m*/
    return new File(project.getBasedir(), file.getPath());
}

From source file:com.textocat.textokit.eval.cas.FileListCasDirectory.java

@Override
protected IOFileFilter getSourceFileFilter() {
    final Set<String> included = Sets.newHashSet();
    List<String> includedSrcList;
    try {/*from w  ww  . ja v  a  2 s.c  o  m*/
        includedSrcList = FileUtils.readLines(listFile, "utf-8");
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    for (String p : includedSrcList) {
        if (StringUtils.isBlank(p)) {
            continue;
        }
        File pFile = new File(p);
        if (pFile.isAbsolute()) {
            included.add(pFile.getAbsolutePath());
        } else {
            included.add(new File(dir, p).getAbsolutePath());
        }
    }
    return FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File f) {
            return included.contains(f.getAbsolutePath());
        }
    });
}

From source file:io.pivotal.strepsirrhini.chaosloris.docs.MarkdownWriterResolver.java

File resolveFile(String outputDirectory, String fileName, RestDocumentationContext context) {
    File outputFile = new File(outputDirectory, fileName);
    if (!outputFile.isAbsolute()) {
        outputFile = makeRelativeToConfiguredOutputDir(outputFile, context);
    }/*w  ww. j a v a  2  s  . c  o  m*/
    return outputFile;
}