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.netflix.nicobar.core.archive.SingleFileScriptArchiveTest.java

@Test
public void testDefaultModuleSpec() throws Exception {
    URL rootPathUrl = getClass().getClassLoader().getResource(TEST_SCRIPTS_PATH.getResourcePath());
    Path rootPath = Paths.get(rootPathUrl.toURI()).toAbsolutePath();
    Set<String> singleFileScripts = TEST_SCRIPTS_PATH.getContentPaths();
    for (String script : singleFileScripts) {
        Path scriptPath = rootPath.resolve(script);
        SingleFileScriptArchive scriptArchive = new SingleFileScriptArchive.Builder(scriptPath).build();
        String moduleId = script.replaceAll("\\.", "_");
        assertEquals(scriptArchive.getModuleSpec().getModuleId().toString(), moduleId);
        Set<String> archiveEntryNames = scriptArchive.getArchiveEntryNames();
        assertEquals(archiveEntryNames.size(), 1);
        for (String entryName : archiveEntryNames) {
            URL entryUrl = scriptArchive.getEntry(entryName);
            assertNotNull(entryUrl);/*from w ww . jav  a 2 s .  c o m*/
            InputStream inputStream = entryUrl.openStream();
            String content = IOUtils.toString(inputStream, Charsets.UTF_8);

            // We have stored the file name as the content of the file
            assertEquals(content, script + lineSeparator());
        }
    }
}

From source file:fr.duminy.jbackup.core.task.BackupTask.java

@Override
protected void executeTask(FileDeleter deleter) throws Exception {
    ArchiveFactory factory = config.getArchiveFactory();

    Path target = Paths.get(config.getTargetDirectory());
    Files.createDirectories(target);

    String archiveName = generateName(config.getName(), config.getArchiveFactory());

    Path archive = target.resolve(archiveName);

    final ArchiveParameters archiveParameters = new ArchiveParameters(archive, config.isRelativeEntries());
    for (BackupConfiguration.Source filter : config.getSources()) {
        IOFileFilter dirFilter = config.createIOFileFilter("_dir", filter.getDirFilter());
        IOFileFilter fileFilter = config.createIOFileFilter("_file", filter.getFileFilter());
        Path source = Paths.get(filter.getPath());
        archiveParameters.addSource(source, dirFilter, fileFilter);
    }//from  w  ww. j av  a 2s  . c om

    deleter.registerFile(archiveParameters.getArchive());

    List<SourceWithPath> collectedFiles = new ArrayList<>();
    createFileCollector().collectFiles(collectedFiles, archiveParameters, listener, cancellable);
    compress(factory, archiveParameters, collectedFiles, cancellable);
}

From source file:it.baeyens.arduino.managers.ArduinoPlatform.java

public List<Path> getIncludePath() {
    Path installPath = getInstallPath();
    return Arrays.asList(installPath.resolve("cores/{build.core}"), //$NON-NLS-1$
            installPath.resolve(Const.VARIANTS_FOLDER_NAME + "/{build.variant}")); //$NON-NLS-1$
}

From source file:eu.itesla_project.cim1.converter.CIM1ImporterTest.java

@Test
public void copy() throws Exception {
    Path testCopyDir = Files.createDirectory(fileSystem.getPath("test_copy"));
    importer.copy(zdsSplit, new FileDataSource(testCopyDir, "newbasename"));
    assertTrue(Files.exists(testCopyDir.resolve("newbasename_EQ.xml")));
    assertTrue(Files.exists(testCopyDir.resolve("newbasename_TP.xml")));
    assertTrue(Files.exists(testCopyDir.resolve("newbasename_SV.xml")));
    assertTrue(Files.exists(testCopyDir.resolve("ENTSO-E_Boundary_Set_EU_EQ.xml")));
    assertTrue(Files.exists(testCopyDir.resolve("ENTSO-E_Boundary_Set_EU_TP.xml")));
}

From source file:at.ac.tuwien.infosys.repository.LocalComponentRepository.java

@Override
public List<Dependency> getDependencies(Component component) throws NotFoundException {

    Path versionedComponentPath = resolve(component.getName(), component.getVersion());

    Path dependencyFilePath = versionedComponentPath.resolve(dependencyFile);

    Dependency[] dependencies = new Dependency[0];
    try {//from  www  .ja v  a 2 s. com
        dependencies = objectMapper.readValue(Files.newInputStream(dependencyFilePath), Dependency[].class);
    } catch (JsonParseException e) {
        throw new NotFoundException("Could not parse found dependency information!", e);
    } catch (JsonMappingException e) {
        throw new NotFoundException("Could not map found dependency information!", e);
    } catch (IOException e) {
        // throw new NotFoundException(
        // "Could not find dependency information!", e);
    }

    return Arrays.asList(dependencies);
}

From source file:org.ng200.openolympus.services.StorageService.java

@PreAuthorize(SecurityExpressionConstants.IS_ADMIN)
public Path createTaskDescriptionFileStorage(Task task) throws IOException {
    final UUID uuid = UUID.randomUUID();
    final String idString = System.currentTimeMillis() + "_" + uuid.toString();
    final Path file = FileSystems.getDefault().getPath(this.storagePath, "tasks", "descriptions", idString);
    FileAccess.createDirectories(file);/*  w w w . jav a 2 s .c o m*/
    FileAccess.createFile(file.resolve("source"));
    task.setDescriptionFile(idString);
    return file;
}

From source file:de.hopmann.msc.slave.util.RCMDBuilder.java

public RCMDBuilder(Path packagePath, Path workingDirectoryBasePath) throws IOException {
    this.packagePath = packagePath;
    workingDirectoryPath = workingDirectoryBasePath.resolve(workingDirectoryId.get() + "");
    Files.createDirectories(workingDirectoryPath);
}

From source file:com.ignorelist.kassandra.steam.scraper.PathResolver.java

public Path findConfiguration() throws IOException {
    Path configPath = Paths.get(System.getProperty("user.home"), ".config", "steam-scraper");
    if (!Files.isDirectory(configPath)) {
        Files.createDirectories(configPath);
    }/*from   ww  w  .j av  a2s.  c  om*/
    return configPath.resolve("steam-scraper.conf");
}

From source file:com.ttech.cordovabuild.domain.application.source.ApplicationSourceFactoryImpl.java

private AssetRef getIconAssetRef(Path sourcePath, DomEditor.IconConfig iconConfig) {
    if (iconConfig == null)
        return null;
    Path path = sourcePath.resolve(iconConfig.getSrc()).normalize();
    if (isSubPath(path, sourcePath) && !path.equals(sourcePath)
            && path.getFileName().toString().toLowerCase().endsWith(".png")) {
        try (InputStream fs = new FileInputStream(path.toFile())) {
            if (iconConfig.getHeight() != null || iconConfig.getWidth() != null) {
                BufferedImage bufferedImage = ImageIO.read(fs);
                bufferedImage = scaleTo(bufferedImage, iconConfig.getHeight(), iconConfig.getWidth());
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                ImageIO.write(bufferedImage, "png", outputStream);
                return assetService.save(new ByteArrayInputStream(outputStream.toByteArray()), "image/png");
            } else
                return assetService.save(fs, "image/png");
        } catch (IOException e) {
            LOGGER.warn("image file cannot be read");
        }/*from  w w  w  .  ja  v  a  2 s  .c  om*/
    }
    return null;
}

From source file:net.minecrell.quartz.launch.QuartzTweaker.java

@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
    Path gamePath = gameDir != null ? gameDir.toPath() : Paths.get("");
    serverJar = gamePath.resolve("bin").resolve(QuartzMain.MINECRAFT_SERVER_LOCAL);
    checkState(Files.exists(serverJar), "Failed to load server JAR");

    boolean jline = true;

    if (args != null && !args.isEmpty()) {
        OptionParser parser = new OptionParser();
        parser.allowsUnrecognizedOptions();
        parser.accepts("gui");
        parser.accepts("nojline"); // TODO: Naming

        OptionSet options = parser.parse(args.toArray(new String[args.size()]));
        gui = options.has("gui");
        jline = !options.has("nojline");
    }/* ww  w. ja v a2  s  .c o  m*/

    QuartzLaunch.initialize(gamePath);

    // Initialize jline
    logger.debug("Initializing JLine...");
    try {
        QuartzConsole.initialize(jline);
    } catch (Throwable t) {
        logger.error("Failed to initialize fancy console", t);
        try {
            QuartzConsole.initializeFallback();
        } catch (IOException e) {
            throw new RuntimeException("Failed to initialize terminal", e);
        }
    }

    QuartzConsole.start();
}