List of usage examples for java.nio.file Path toString
String toString();
From source file:com.github.cbismuth.fdupes.collect.PathAnalyser.java
public Optional<Path> getTimestampPath(final Path destination, final Path path) { final Optional<Path> result; final String name = FilenameUtils.getName(path.toString()); final Matcher matcher_1 = PATTERN_1.matcher(name); if (matcher_1.matches()) { result = Optional.of(onMatch(destination, matcher_1)); } else {//from ww w. j a va 2s . com final Matcher matcher_2 = PATTERN_2.matcher(name); if (matcher_2.matches()) { result = Optional.of(onMatch(destination, matcher_2)); } else { LOGGER.warn("File [{}] doesn't match pattern", path); result = Optional.empty(); } } return result; }
From source file:io.fabric8.vertx.maven.plugin.utils.IncrementalBuilder.java
/** * Adds an observer listening for changes in the given path. * * @param path the path to observe/*from w ww . java2s . c o m*/ */ protected synchronized void buildObserver(Path path) { logger.info("Observing path:" + path.toString()); FileAlterationObserver observer = new FileAlterationObserver(path.toFile()); observer.addListener(this); observers.put(path, observer); this.monitor.addObserver(observer); }
From source file:org.wte4j.examples.showcase.server.services.OrderServiceImpl.java
@Override public String createDocument(OrderDataDto order, String documentName) { try {//from w ww. j a va 2 s . c o m Path file = templateEngine.createDocument(documentName, "en", order); return file.toString(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.github.zhanhb.ckfinder.connector.handlers.command.BaseCommand.java
@SuppressWarnings("FinalMethod") protected final Path getPath(Path first, String... more) { return first.getFileSystem().getPath(first.toString(), more); }
From source file:com.github.cbismuth.fdupes.io.PathOrganizer.java
private void onNoTimestampPath(final Path destination, final PathElement pathElement, final AtomicInteger counter) { final Path path = pathElement.getPath(); final String baseName = FilenameUtils.getBaseName(path.toString()); final int count = counter.getAndIncrement(); final String extension = FilenameUtils.getExtension(path.toString()); final String newName = String.format("%s-%d.%s", baseName, count, extension); final Path sibling = path.resolveSibling(newName); try {//from w w w . j a va 2s . c om FileUtils.moveFile(path.toFile(), sibling.toFile()); FileUtils.moveFileToDirectory(sibling.toFile(), Paths.get(destination.toString(), "misc").toFile(), true); } catch (final IOException e) { LOGGER.error(e.getMessage()); } }
From source file:ee.ria.xroad.signer.certmanager.FileBasedOcspCache.java
boolean isOcspFile(Path p) { return Files.isRegularFile(p) && p.toString().endsWith(OCSP_FILE_EXTENSION); }
From source file:gndata.lib.srv.LocalFileTest.java
@Test public void testGetPath() throws Exception { Path filePath = localFile.getPath(); assertThat(filePath.toString()).isNotEmpty(); assertThat(filePath).isAbsolute();//from ww w. ja v a 2s .com }
From source file:at.tfr.securefs.data.ProcessFilesData.java
public void putError(Path path, Exception e) { errors.put(path.toString(), abbreviate(e)); }
From source file:com.evolveum.midpoint.model.impl.ExtensionSchemaRestService.java
private String computeName(String midpointHome, SchemaDescription description) { String path = description.getPath(); if (path == null) { return null; }// w w w . j a v a 2 s . c om File file = new File(path); if (!file.exists()) { return null; } File home = new File(midpointHome, "/schema"); java.nio.file.Path homePath = home.toPath(); java.nio.file.Path filePath = file.toPath(); java.nio.file.Path relative = homePath.relativize(filePath); return relative.toString(); }
From source file:at.tfr.securefs.client.SecurefsClient.java
public void run() { DateTime start = new DateTime(); try (FileSystem fs = FileSystems.newFileSystem(new URI(baseDir), null)) { for (Path path : files) { Path sec = fs.getPath(path.toString() + (asyncTest ? "." + Thread.currentThread().getId() : "")); if (write) { if (!path.toFile().exists()) { System.err.println(Thread.currentThread() + ": NoSuchFile: " + path + " currentWorkdir=" + Paths.get("./").toAbsolutePath()); continue; }/*from ww w. j av a2 s .c om*/ if (path.getParent() != null) { fs.provider().createDirectory(fs.getPath(path.getParent().toString())); } final OutputStream secOs = Files.newOutputStream(sec); System.out.println(Thread.currentThread() + ": Sending file: " + start + " : " + sec); IOUtils.copyLarge(Files.newInputStream(path), secOs, new byte[128 * 1024]); secOs.close(); } Path out = path.resolveSibling( path.getFileName() + (asyncTest ? "." + Thread.currentThread().getId() : "") + ".out"); if (read) { System.out.println(Thread.currentThread() + ": Reading file: " + new DateTime() + " : " + out); if (out.getParent() != null) { Files.createDirectories(out.getParent()); } final InputStream secIs = Files.newInputStream(sec); IOUtils.copyLarge(secIs, Files.newOutputStream(out), new byte[128 * 1024]); secIs.close(); } if (write && read) { long inputChk = FileUtils.checksumCRC32(path.toFile()); long outputChk = FileUtils.checksumCRC32(out.toFile()); if (inputChk != outputChk) { throw new IOException(Thread.currentThread() + ": Checksum Failed: failure to write/read: in=" + path + ", out=" + out); } System.out.println(Thread.currentThread() + ": Checked Checksums: " + new DateTime() + " : " + inputChk + " / " + outputChk); } if (delete) { boolean deleted = fs.provider().deleteIfExists(sec); if (!deleted) { throw new IOException( Thread.currentThread() + ": Delete Failed: failure to delete: in=" + path); } else { System.out.println(Thread.currentThread() + ": Deleted File: in=" + path); } } } } catch (Throwable t) { t.printStackTrace(); throw new RuntimeException(t); } }