List of usage examples for java.nio.file Path resolve
default Path resolve(String other)
From source file:com.collaborne.jsonschema.generator.pojo.PojoGeneratorSmokeTest.java
@After public void tearDown() throws IOException { // Dump the contents of the file system Path dumpStart = fs.getPath("/"); Files.walkFileTree(dumpStart, new SimpleFileVisitor<Path>() { @Override/*from w w w .j a va2 s. com*/ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { System.out.println("> " + file); System.out.println(new String(Files.readAllBytes(file), StandardCharsets.UTF_8)); // Copy the file if wanted if (DUMP_DIRECTORY != null) { Path dumpTarget = Paths.get(DUMP_DIRECTORY, name.getMethodName()); Path target = dumpTarget.resolve(dumpStart.relativize(file).toString()); Files.createDirectories(target.getParent()); Files.copy(file, target, StandardCopyOption.REPLACE_EXISTING); } return FileVisitResult.CONTINUE; } }); }
From source file:de.ncoder.studipsync.storage.StandardPathResolver.java
@Override public Path resolve(Path root, Download download, Path srcFile) { if (srcFile.isAbsolute()) { srcFile = srcFile.getRoot().relativize(srcFile); }//from w ww . j a v a2s . c om Path dstRoot = resolve(root, download).getParent(); //only dir in root of src == dir of download ("Hauptordner") Path dstPath = dstRoot.resolve(srcFile.toString()); log.debug(dstPath + " = " + dstRoot + " <~ " + srcFile); return dstPath; }
From source file:com.ignorelist.kassandra.steam.scraper.PathResolver.java
public Set<Path> findAllLibraryDirectories() throws IOException, RecognitionException { Path steamApps = findSteamApps(); Set<Path> libraryDirectories = new LinkedHashSet<>(); libraryDirectories.add(steamApps);/*from w w w . j a v a 2 s .co m*/ Path directoryDescriptor = steamApps.resolve("libraryfolders.vdf"); if (Files.exists(directoryDescriptor)) { InputStream vdfStream = Files.newInputStream(directoryDescriptor, StandardOpenOption.READ); VdfRoot vdfRoot = VdfParser.parse(vdfStream); IOUtils.closeQuietly(vdfStream); final VdfNode nodeLibrary = Iterables.getFirst(vdfRoot.getChildren(), null); if (null != nodeLibrary) { for (VdfAttribute va : nodeLibrary.getAttributes()) { //System.err.println(va); try { Integer.parseInt(va.getName()); Path libraryDirectory = Paths.get(va.getValue()); libraryDirectories.add(resolveAppsDirectory(libraryDirectory)); } catch (NumberFormatException nfe) { } catch (IllegalStateException ise) { System.err.println(ise); } } } } return libraryDirectories; }
From source file:com.dickthedeployer.dick.web.service.RepositoryService.java
public InputStream getFile(Build build, String filePath) { Repo repo = new Repo(build.getProject().getName(), build.getRepository(), build.getRef()); REPOS.computeIfAbsent(repo, key -> checkoutRepository(key)); Path path = REPOS.get(repo); synchronized (path) { checkoutRevision(path, build.getRef(), build.getSha()); Path file = path.resolve(filePath); try {/*from w w w. ja va 2 s.com*/ if (Files.exists(file)) { return Files.newInputStream(file); } else { return null; } } catch (IOException ex) { throw Throwables.propagate(ex); } } }
From source file:ch.sourcepond.maven.plugin.jenkins.config.download.DownloaderImpl.java
/** * @param pJenkinscliDirectory// w ww . jav a 2 s .co m * @param pJenkinsVersion * @return * @throws IOException */ private Path getDownloadedCliJar(final Path pJenkinscliDirectory, final String pJenkinsVersion) throws IOException { final Path downloadDirectory = pJenkinscliDirectory.resolve(pJenkinsVersion); if (!isDirectory(downloadDirectory)) { createDirectories(downloadDirectory); } return downloadDirectory.resolve(JAR_NAME); }
From source file:com.google.cloud.tools.gradle.appengine.sourcecontext.SourceContextPluginIntegrationTest.java
/** Create a test project with git source context. */ public void setUpTestProject() throws IOException { Path buildFile = testProjectDir.getRoot().toPath().resolve("build.gradle"); Path src = Files.createDirectory(testProjectDir.getRoot().toPath().resolve("src")); InputStream buildFileContent = getClass().getClassLoader() .getResourceAsStream("projects/sourcecontext-project/build.gradle"); Files.copy(buildFileContent, buildFile); Path gitContext = testProjectDir.getRoot().toPath().resolve("gitContext.zip"); InputStream gitContextContent = getClass().getClassLoader() .getResourceAsStream("projects/sourcecontext-project/gitContext.zip"); Files.copy(gitContextContent, gitContext); try (ZipFile zipFile = new ZipFile(gitContext.toFile())) { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); File entryDestination = new File(testProjectDir.getRoot(), entry.getName()); if (entry.isDirectory()) { entryDestination.mkdirs(); } else { entryDestination.getParentFile().mkdirs(); InputStream in = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(entryDestination); IOUtils.copy(in, out);// w w w . j a v a2 s . c om IOUtils.closeQuietly(in); out.close(); } } } FileUtils.delete(gitContext.toFile()); Path webInf = testProjectDir.getRoot().toPath().resolve("src/main/webapp/WEB-INF"); Files.createDirectories(webInf); File appengineWebXml = Files.createFile(webInf.resolve("appengine-web.xml")).toFile(); Files.write(appengineWebXml.toPath(), "<appengine-web-app/>".getBytes(Charsets.UTF_8)); }
From source file:cc.kave.commons.pointsto.evaluation.TimeEvaluation.java
public void exportResults(Path outputDir, ResultExporter exporter) throws IOException { Function<Double, String> format = number -> String.format(Locale.US, "%.3f", number); exporter.export(outputDir.resolve("TimeStatistics.txt"), analysisStatistics.entrySet().stream().map(entry -> { DescriptiveStatistics stats = entry.getValue(); return new String[] { entry.getKey(), format.apply(stats.getMin()), format.apply(stats.getStandardDeviation()), format.apply(stats.getMean()), format.apply(stats.getMax()) }; }));/* www.j a v a 2 s . com*/ exporter.export(outputDir.resolve("StmtCountTimes.txt"), analysisTimes.stream() .map(entry -> new String[] { entry.analysisName, entry.contextType.getFullName(), Integer.toString(entry.numStmts), format.apply(entry.time) })); }
From source file:io.redlink.solrlib.cloud.SolrCloudConnector.java
private void uploadConfig(final String remoteName, final Path coreDict) throws IOException { try (ZkClientClusterStateProvider zkClient = createZkClient()) { zkClient.uploadConfig(coreDict.resolve("conf"), remoteName); }//from w w w . j a va 2 s . c o m }
From source file:org.opentestsystem.ap.ivs.service.ValidationUtility.java
public Path mapItemToValidationStructure(final ItemContext itemContext, final Path validationRootChild) { return Objects.nonNull(itemContext) ? mapToValidationStructure(itemContext, validationRootChild.resolve(ITEMS_DIR), mapItemFolderName(itemContext.getItemId())) : null;//from www. ja va 2 s . c o m }
From source file:org.opentestsystem.ap.ivs.service.ValidationUtility.java
public Path mapStimulusToValidationStructure(ItemContext stimulusContext, Path validationRootChild) { return Objects.nonNull(stimulusContext) ? mapToValidationStructure(stimulusContext, validationRootChild.resolve(STIMULI_DIR), mapStimFolderName(stimulusContext.getItemId())) : null;/*from ww w . j av a 2 s . c o m*/ }