Example usage for java.nio.file Paths get

List of usage examples for java.nio.file Paths get

Introduction

In this page you can find the example usage for java.nio.file Paths get.

Prototype

public static Path get(URI uri) 

Source Link

Document

Converts the given URI to a Path object.

Usage

From source file:azkaban.webapp.AzkabanWebServerTest.java

private static String getSqlScriptsDir() throws IOException {
    // Dummy because any resource file works.
    final String dummyResourcePath = getUserManagerXmlFile();
    Path resources = Paths.get(dummyResourcePath).getParent();
    Path azkabanRoot = resources.getParent().getParent().getParent().getParent();

    File sqlScriptDir = Paths.get(azkabanRoot.toString(), AZKABAN_DB_SQL_PATH).toFile();
    return sqlScriptDir.getCanonicalPath();
}

From source file:com.netflix.nicobar.core.module.ScriptModuleUtils.java

/**
 * Create module path from module moduleIdentifier.
 * @param moduleIdentifier module identifier to create path for
 * @return path to module for given moduleIdentifier
 *///from   ww w.j  a va 2  s  .c om
public static Path createModulePath(ModuleIdentifier moduleIdentifier) {
    return Paths.get(moduleIdentifier.getName() + "-" + moduleIdentifier.getSlot());
}

From source file:io.hightide.TemplateFetcher.java

public static Path getPrototype(Path tempDir, String templateName) throws IOException {
    if (isNull(templateName)) {
        return null;
    }/*from  www.  j a va 2 s.c om*/
    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:fi.jumi.core.config.SuiteConfiguration.java

public SuiteConfiguration() {
    classpath = Collections.emptyList();
    jvmOptions = Collections.emptyList();
    workingDirectory = Paths.get(".").normalize().toUri();
    includedTestsPattern = "glob:**Test.class";
    excludedTestsPattern = "glob:**$*.class";
}

From source file:pl.p.lodz.ftims.server.logic.ChallengeServiceTest.java

@AfterClass
public static void deleteImgDir() throws IOException {
    Stream<Path> stream = Files.list(Paths.get(PHOTOS_DIR));
    stream.forEach((Path p) -> {
        try {/*w  w  w  .j  av a 2s  .co m*/
            Files.delete(p);
        } catch (IOException ex) {
            Logger.getLogger(ChallengeServiceTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    Files.deleteIfExists(Paths.get(PHOTOS_DIR));
}

From source file:azkaban.soloserver.AzkabanSingleServerTest.java

private static String getSqlScriptsDir() throws IOException {
    // Dummy because any resource file works.
    Path resources = Paths.get(getConfPath()).getParent();
    Path azkabanRoot = resources.getParent().getParent().getParent().getParent();

    File sqlScriptDir = Paths.get(azkabanRoot.toString(), AZKABAN_DB_SQL_PATH).toFile();
    return sqlScriptDir.getCanonicalPath();
}

From source file:com.example.PathTests.java

@Test
public void test() throws Exception {
    ClassPathResource classPath = new ClassPathResource("");
    System.err.println(classPath.getURL().toString());
    System.err.println(Paths.get(new FileSystemResource(new FileSystemResource("src/main/resources").getURL()
            .toURI().toString().substring("file:".length())).getFile().toURI()).isAbsolute());
}

From source file:io.undertow.server.handlers.RangeRequestTestCase.java

@BeforeClass
public static void setup() throws URISyntaxException {
    Path rootPath = Paths.get(RangeRequestTestCase.class.getResource("range.txt").toURI()).getParent();
    PathHandler path = Handlers.path();// ww  w  .j av  a  2s .  com
    path.addPrefixPath("/path", new ByteRangeHandler(new HttpHandler() {
        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            exchange.getResponseHeaders().put(Headers.LAST_MODIFIED, DateUtils.toDateString(new Date(10000)));
            exchange.getResponseHeaders().put(Headers.ETAG, "\"someetag\"");
            exchange.getResponseSender().send("0123456789");
        }
    }, true));
    path.addPrefixPath("/resource",
            new ResourceHandler(new PathResourceManager(rootPath, 10485760)).setDirectoryListingEnabled(true));
    path.addPrefixPath("/cachedresource",
            new ResourceHandler(new CachingResourceManager(1000, 1000000,
                    new DirectBufferCache(1000, 10, 10000), new PathResourceManager(rootPath, 10485760), -1))
                            .setDirectoryListingEnabled(true));
    DefaultServer.setRootHandler(path);
}

From source file:eu.itesla_project.computation.mpi.ExportTasksStatisticsTool.java

@Override
public void run(CommandLine line) throws Exception {
    Path statisticsDbDir = Paths.get(line.getOptionValue("statistics-db-dir"));
    String statisticsDbName = line.getOptionValue("statistics-db-name");
    Path outputFile = Paths.get(line.getOptionValue("output-file"));
    try (MpiStatistics statistics = new CsvMpiStatistics(statisticsDbDir, statisticsDbName)) {
        try (Writer writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) {
            statistics.exportTasksToCsv(writer);
        }/* w  ww. jav a  2 s . c o m*/
    }
}

From source file:edu.vassar.cs.cmpu331.tvi.Main.java

private static void renumber(String filename) throws IOException {
    Path file = Paths.get(filename);
    if (Files.notExists(file)) {
        System.out.println("File not found: " + filename);
        return;/* ww  w  .j a  va  2s.c om*/
    }
    System.out.println("Renumbering " + filename);
    Function<String, String> trim = s -> {
        int i = s.indexOf(':');
        if (i > 0) {
            return s.substring(i + 1).trim();
        }
        return s.trim();
    };
    List<String> list = Files.lines(file).filter(line -> !line.startsWith("CODE")).map(line -> trim.apply(line))
            .collect(Collectors.toList());
    int size = list.size();
    PrintWriter writer = new PrintWriter(Files.newBufferedWriter(file));
    //      PrintStream writer = System.out;
    writer.println("CODE");
    IntStream.range(0, size).forEach(index -> {
        String line = list.get(index);

        writer.println(index + ": " + line);
    });
    writer.close();
    System.out.println("Done.");
}