Example usage for java.nio.file Path resolve

List of usage examples for java.nio.file Path resolve

Introduction

In this page you can find the example usage for java.nio.file Path resolve.

Prototype

default Path resolve(String other) 

Source Link

Document

Converts a given path string to a Path and resolves it against this Path in exactly the manner specified by the #resolve(Path) resolve method.

Usage

From source file:com.arcbees.gwtpolymer.ComponentPathUtilsImpl.java

@Override
public File getPublicDirectory(Path componentTargetDirectory, String name) {
    return componentTargetDirectory.resolve(PUBLIC).resolve(name).toFile();
}

From source file:eu.itesla_project.iidm.ddb.eurostag_imp_exp.tools.DdbLoaderTool.java

@Override
public void run(CommandLine line) throws Exception {
    String dataDir = line.getOptionValue(DdbLoaderCommand.DATA_DIR);
    String jbossHost = line.getOptionValue(DdbLoaderCommand.HOST);
    String jbossPort = line.getOptionValue(DdbLoaderCommand.PORT);
    String jbossUser = line.getOptionValue(DdbLoaderCommand.USER);
    String jbossPassword = line.getOptionValue(DdbLoaderCommand.PASSWORD);
    String eurostagVersion = line.getOptionValue(DdbLoaderCommand.EUROSTAG_VERSION);

    DdbConfig ddbConfig = new DdbConfig(jbossHost, jbossPort, jbossUser, jbossPassword);
    Path ddData = Paths.get(dataDir);
    Path ddPath = ddData.resolve("gene");
    Path genPath = ddData.resolve("reguls");
    Path dicoPath = ddData.resolve("dico.txt");
    DynDataLoader dn = new DynDataLoader(dicoPath, ddPath, genPath, eurostagVersion, //"5.1.1",
            ddbConfig.getJbossHost(), ddbConfig.getJbossPort(), ddbConfig.getJbossUser(),
            ddbConfig.getJbossPassword());
    dn.loadDynData();//from   w ww. j  av  a2 s  .  c om
}

From source file:cc.kave.commons.pointsto.evaluation.PointsToSetEvaluation.java

public void exportResults(Path evaluationDir, ResultExporter exporter) throws IOException {
    exporter.export(evaluationDir.resolve(getClass().getSimpleName() + ".txt"),
            results.stream().map(setSize -> new String[] { setSize.toString() }));
}

From source file:org.bonitasoft.web.designer.repository.AbstractLoader.java

public Path jsonFile(Path directory, String id) {
    return directory.resolve(id).resolve(id + ".json");
}

From source file:fi.jumi.launcher.daemon.DirBasedSteward.java

@Override
public Path createDaemonDir(Path jumiHome) {
    try {//from w w  w . java 2s . co m
        return UniqueDirectories.createUniqueDir(jumiHome.resolve(DAEMONS_DIR), System.currentTimeMillis());
    } catch (IOException e) {
        throw new RuntimeException("Unable to create daemon directory", e);
    }
}

From source file:fr.pilato.elasticsearch.crawler.fs.framework.FsCrawlerUtil.java

/**
 * Unzip a jar file/* ww w  .j a va 2s. com*/
 * @param jarFile Jar file url like file:/path/to/foo.jar
 * @param destination Directory where we want to extract the content to
 * @throws IOException In case of any IO problem
 */
public static void unzip(String jarFile, Path destination) throws IOException {
    Map<String, String> zipProperties = new HashMap<>();
    /* We want to read an existing ZIP File, so we set this to false */
    zipProperties.put("create", "false");
    zipProperties.put("encoding", "UTF-8");
    URI zipFile = URI.create("jar:" + jarFile);

    try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, zipProperties)) {
        Path rootPath = zipfs.getPath("/");
        Files.walkFileTree(rootPath, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                Path targetPath = destination.resolve(rootPath.relativize(dir).toString());
                if (!Files.exists(targetPath)) {
                    Files.createDirectory(targetPath);
                }
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Files.copy(file, destination.resolve(rootPath.relativize(file).toString()),
                        StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
                return FileVisitResult.CONTINUE;
            }
        });
    }
}

From source file:com.cloudbees.clickstack.util.Files2.java

/**
 * Copy content for {@code srcDir} to {@code destDir}
 *
 * @param srcDir//from   w w  w . ja v  a 2  s .  co m
 * @param destDir
 * @throws RuntimeIOException
 */
public static void copyDirectoryContent(@Nonnull final Path srcDir, @Nonnull final Path destDir)
        throws RuntimeIOException {
    logger.trace("Copy from {} to {}", srcDir, destDir);

    FileVisitor<Path> copyDirVisitor = new SimpleFileVisitor<Path>() {

        @Override
        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
            Path targetPath = destDir.resolve(srcDir.relativize(dir));
            if (!Files.exists(targetPath)) {
                Files.createDirectory(targetPath);
            }
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            Files.copy(file, destDir.resolve(srcDir.relativize(file)), StandardCopyOption.REPLACE_EXISTING);
            return FileVisitResult.CONTINUE;
        }
    };
    try {
        Files.walkFileTree(srcDir, copyDirVisitor);
    } catch (IOException e) {
        throw new RuntimeIOException("Exception copying content of dir " + srcDir + " to " + destDir, e);
    }
}

From source file:io.hightide.TemplateFetcher.java

public static Path getPrototype(Path tempDir, String templateName) throws IOException {
    if (isNull(templateName)) {
        return null;
    }/*from  w  w  w  .  j  a va 2  s .  com*/
    String[] tkns;
    if ((tkns = templateName.split(":")).length < 2) {
        return null;
    }

    String templateType = tkns[0];
    String orgProj;
    switch (templateType) {
    case "file":
        String filePath = tkns[1];
        Path file = Paths.get(filePath);
        if (filePath.endsWith(".tar.gz")) {
            return extractTemplate(file, tempDir);
        } else {
            // Copy dir
            if (Files.isDirectory(file)) {
                return file;
            }
        }
        return null;
    case "git":
        //git archive master --remote=<repo>| gzip > archive.tar.gz
    case "github":
        orgProj = tkns[1];
        System.out.println("Downloading template from github.com");

        httpGetTemplate(tempDir.resolve(TEMP_ARCHIVE_NAME),
                "http://github.com/" + orgProj + "/archive/master.tar.gz");
        return extractTemplate(tempDir.resolve(TEMP_ARCHIVE_NAME));
    case "bitbucket":
        orgProj = tkns[1];
        System.out.println("Downloading template from bitbucket.org");
        httpGetTemplate(tempDir.resolve(TEMP_ARCHIVE_NAME),
                "http://bitbucket.org/" + orgProj + "/get/master.tar.gz");
        return extractTemplate(tempDir.resolve(TEMP_ARCHIVE_NAME));
    case "url":
        String fileUrl = tkns[1];
        System.out.println("Downloading template archive from " + fileUrl);
        httpGetTemplate(tempDir.resolve(TEMP_ARCHIVE_NAME), fileUrl);
        return extractTemplate(tempDir.resolve(TEMP_ARCHIVE_NAME));
    default:
        return null;
    }
}

From source file:edu.cornell.library.scholars.webapp.controller.api.distribute.file.FileDistributor.java

@Override
public void writeOutput(OutputStream output) throws DataDistributorException {
    Path home = ApplicationUtils.instance().getHomeDirectory().getPath();
    Path datafile = home.resolve(datapath);
    log.debug("data file is at: " + datapath);
    try (InputStream input = Files.newInputStream(datafile)) {
        IOUtils.copy(input, output);//w w  w  . j  av a 2 s  .c  om
    } catch (IOException e) {
        throw new ActionFailedException(e);
    }
}

From source file:io.undertow.server.handlers.accesslog.ExtendedAccessLogFileTestCase.java

@Test
public void testSingleLogMessageToFile() throws IOException, InterruptedException {
    Path directory = logDirectory;
    Path logFileName = directory.resolve("extended.log");
    DefaultAccessLogReceiver logReceiver = DefaultAccessLogReceiver.builder()
            .setLogWriteExecutor(DefaultServer.getWorker()).setOutputDirectory(directory)
            .setLogBaseName("extended.")
            .setLogFileHeaderGenerator(new ExtendedAccessLogParser.ExtendedAccessLogHeaderGenerator(PATTERN))
            .build();/*from w  w  w.  j  a v a  2s.c  o m*/
    verifySingleLogMessageToFile(logFileName, logReceiver);
}