List of usage examples for java.nio.file Path resolve
default Path resolve(String other)
From source file:com.opensymphony.xwork2.util.fs.JarEntryRevisionTest.java
private String createJarFile(long time) throws Exception { Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); Path jarPath = Paths .get(Thread.currentThread().getContextClassLoader().getResource("xwork-jar.jar").toURI()) .getParent();/* w ww . j a v a 2 s .c om*/ File jarFile = jarPath.resolve("JarEntryRevisionTest_testNeedsReloading.jar").toFile(); FileOutputStream fos = new FileOutputStream(jarFile, false); JarOutputStream target = new JarOutputStream(fos, manifest); target.putNextEntry(new ZipEntry("com/opensymphony/xwork2/util/fs/")); ZipEntry entry = new ZipEntry("com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class"); entry.setTime(time); target.putNextEntry(entry); InputStream source = getClass() .getResourceAsStream("/com/opensymphony/xwork2/util/fs/JarEntryRevisionTest.class"); IOUtils.copy(source, target); source.close(); target.closeEntry(); target.close(); fos.close(); return jarFile.toURI().toURL().toExternalForm(); }
From source file:io.jeo.geopkg.GeoPkgFeatureTest.java
@Before public void setUp() throws Exception { Path dir = unzip(getClass().getResourceAsStream("usa.gpkg.zip"), newTmpDir()); geopkg = GeoPackage.open(dir.resolve("usa.gpkg")); }
From source file:org.opentestsystem.ap.ivs.service.ValidationUtility.java
private Path mapToValidationStructure(final ItemContext itemContext, final Path itemValidationParent, final String baseFolderName) { final String itemId = itemContext.getItemId(); final Path itemValidationRepoPath = itemValidationParent.resolve(baseFolderName); final Path itemValidationFilePath = itemValidationRepoPath.resolve(mapFileName(itemId)); final Path itemValidationAdjustedFilePath = itemValidationRepoPath.resolve(mapFileName(baseFolderName)); try {// w w w. java2 s . c o m FileUtils.copyDirectory(itemContext.getLocalRepositoryPath().toFile(), itemValidationRepoPath.toFile()); itemValidationFilePath.toFile().renameTo(itemValidationAdjustedFilePath.toFile()); } catch (IOException e) { throw new SystemException("Error copying item " + itemId + " for validation", e); } return itemValidationRepoPath; }
From source file:com.qwazr.library.archiver.ArchiverTest.java
@Test public void extractDir() throws IOException, ArchiveException, CompressorException { Path destDir = Files.createTempDirectory("archiverToolTest"); Assert.assertNotNull(gzipArchiver);/*from ww w .j a va 2s. c om*/ gzipArchiver.decompress_dir("src/test/resources/com/qwazr/library/archiver", "gz", destDir.toAbsolutePath().toString()); Assert.assertTrue(Files.exists(destDir.resolve("test1.tar"))); Assert.assertTrue(Files.exists(destDir.resolve("test2.tar"))); Assert.assertNotNull(archiver); archiver.extract_dir(destDir.toAbsolutePath().toString(), "tar", destDir.toAbsolutePath().toString(), false); Assert.assertTrue(Files.exists(destDir.resolve("test1"))); Assert.assertTrue(Files.exists(destDir.resolve("test2"))); }
From source file:neembuu.uploader.zip.generator.NUZipFileGenerator.java
private void handleClassEntry(Path pathInZip, final Class c, FileSystem fs, Path uploadersDirectory) throws IOException { Path classLocationOnDisk = uploadersDirectory.resolve(pathInZip.toString()); DirectoryStream<Path> ds = Files.newDirectoryStream(classLocationOnDisk, new DirectoryStream.Filter<Path>() { @Override//w w w. j a v a 2s . com public boolean accept(Path entry) throws IOException { String fn = entry.getFileName().toString(); String cn = c.getSimpleName(); return fn.equals(cn + ".class") || fn.startsWith(cn + "$"); } }); for (Path p : ds) { byte[] b = Files.readAllBytes(p); Files.write(pathInZip.resolve(p.getFileName().toString()), b); } // say we want to zie SomeClass.class // then we also need to zip SomeClass$1.class // That is, we also need to zip inner classes and inner annoymous classes // into the zip as well }
From source file:it.tidalwave.bluemarine2.downloader.impl.SimpleHttpCacheStorage.java
/******************************************************************************************************************* * * {@inheritDoc}//from w ww. j a v a2 s . c o m * ******************************************************************************************************************/ @Override public HttpCacheEntry getEntry(final @Nonnull String key) throws IOException { log.debug("getEntry({})", key); final Path cachePath = getCacheItemPath(new URL(key)); final Path cacheHeadersPath = cachePath.resolve(PATH_HEADERS); final Path cacheContentPath = cachePath.resolve(PATH_CONTENT); if (!exists(cacheHeadersPath)) { log.trace(">>>> cache miss: {}", cacheHeadersPath); return null; } try { @Cleanup final InputStream is = newInputStream(cacheHeadersPath); final SessionInputBufferImpl sib = sessionInputBufferFrom(is); final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(sib); return entryFrom(cacheContentPath, parser.parse()); } catch (HttpException e) { throw new IOException(e); } }
From source file:com.netflix.nicobar.core.archive.SingleFileScriptArchiveTest.java
@Test public void testWithModuleSpec() 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(); ModuleId moduleId = ModuleId.create("testModuleId"); for (String script : singleFileScripts) { Path scriptPath = rootPath.resolve(script); SingleFileScriptArchive scriptArchive = new SingleFileScriptArchive.Builder(scriptPath) .setModuleSpec(new ScriptModuleSpec.Builder(moduleId).build()).build(); assertEquals(scriptArchive.getModuleSpec().getModuleId(), moduleId); // We just need to test one script in the set break;/* www .j a va 2 s . com*/ } }
From source file:cn.edu.zjnu.acm.judge.core.Judger.java
private Path getNull(Path work) { return File.pathSeparatorChar == ';' ? work.resolve("NUL") : Paths.get("/dev/null"); }
From source file:api.wiki.WikiGenerator.java
private Path copyToReleaseDirectory(Path file, Path releaseDirectory) { try {/*from w ww . j av a 2s . c o m*/ Path target = releaseDirectory .resolve(file.subpath(wikiDirectory().getNameCount(), file.getNameCount())); Files.createDirectories(target.subpath(1, target.getNameCount() - 1)); return Files.copy(file, target); } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:com.pawandubey.griffin.model.Page.java
/** * @return the permalink, as decided by whether the user has specified a * custom slug or not. If the slug is not specified, then the permalink is * constructed from the post-title//from w ww .j ava 2s . c om */ @Override public String getPermalink() { Path parentDir = Paths.get(SOURCE_DIRECTORY).relativize(Paths.get(location).getParent()); permalink = Data.config.getSiteBaseUrl().concat("/").concat(parentDir.resolve(getSlug()).toString()) .concat("/"); return permalink; }