List of usage examples for java.nio.file Files delete
public static void delete(Path path) throws IOException
From source file:org.phenotips.variantstore.input.vcf.VCFManager.java
@Override public void removeIndividual(String id) throws InputException { try {//from w w w . ja va2 s . co m Files.delete(this.getIndividual(id)); } catch (IOException e) { throw new InputException("Error removing VCF", e); } }
From source file:org.phenotips.variantstore.input.exomiser6.tsv.Exomiser6TSVManager.java
@Override public void removeIndividual(String id) throws InputException { try {/*from ww w . j av a 2 s . co m*/ Files.delete(this.getIndividual(id)); } catch (IOException e) { throw new InputException("Error removing TSV", e); } }
From source file:de.ks.file.FileStoreTest.java
@Before public void setUp() throws Exception { controller.startOrResume(new ActivityHint(AddThoughtActivity.class)); cleanup.cleanup();//from w w w .ja va 2 s . c o m fileStoreDir = TMPDIR + File.separator + "idnadrevTestStore"; Options.store(fileStoreDir, FileOptions.class).getFileStoreDir(); File file = new File(fileStoreDir); if (file.exists()) { Files.walkFileTree(file.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; } }); } }
From source file:org.talend.dataprep.cache.file.FileSystemContentCacheJanitor.java
/** * A clean up process that starts a minute after the previous ended. *///from w ww. j a va2 s . co m @Scheduled(fixedDelay = 60000) public void janitor() { if (!Paths.get(location).toFile().exists()) { LOGGER.debug("No cache content to clean."); return; } final long start = System.currentTimeMillis(); final AtomicLong deletedCount = new AtomicLong(); final AtomicLong totalCount = new AtomicLong(); LOGGER.debug("Janitor process started @ {}.", start); try { final BiConsumer<Path, String> deleteOld = (file, suffix) -> { try { final long time = Long.parseLong(suffix); if (time < start) { try { Files.delete(file); deletedCount.incrementAndGet(); } catch (NoSuchFileException e) { LOGGER.debug("Ignored delete issue for '{}'.", file.getFileName(), e); } catch (IOException e) { LOGGER.warn("Unable to delete '{}'.", file.getFileName()); LOGGER.debug("Unable to delete '{}'.", file.getFileName(), e); } } } catch (NumberFormatException e) { LOGGER.debug("Ignore file '{}'", file); } totalCount.incrementAndGet(); }; Files.walkFileTree(Paths.get(location), new FileSystemVisitor(deleteOld)); } catch (IOException e) { LOGGER.error("Unable to clean up cache", e); } LOGGER.debug("Janitor process ended @ {} ({}/{} files successfully deleted).", System.currentTimeMillis(), deletedCount, totalCount); }
From source file:org.opendatakit.briefcase.reused.UncheckedFiles.java
public static void delete(Path path) { try {// w w w .j ava2s . c o m Files.delete(path); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.wandoulabs.jodis.TestRoundRobinJedisPool.java
private void deleteDirectory(File directory) throws IOException { if (!directory.exists()) { return;/*from www.java2 s . c om*/ } Files.walkFileTree(directory.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; } }); }
From source file:org.rapidpm.microservice.optionals.service.ServiceWrapper.java
private static void shutdownMicroservice() { String restBaseUrl = buildBaseUrl(); Optional<Annotation> pathAnnotation = getAnnotation(); if (pathAnnotation.isPresent()) { sendShutdownToService(restBaseUrl, pathAnnotation); } else {//from ww w . j a v a 2 s . c o m LOGGER.warning( "Could not locate Path of rest service. Could it be you forgot to add the admin optional?"); exitHandler.exit(1); } try { Files.delete(MICROSERVICE_REST_FILE); } catch (IOException e) { LOGGER.warning("Could not delete file " + MICROSERVICE_REST_FILE + "Cleanup file before restart"); exitHandler.exit(1); } }
From source file:org.ng200.openolympus.FileAccess.java
public static void delete(final Path path) throws IOException { Files.delete(path); }
From source file:com.linecorp.armeria.server.http.file.HttpFileServiceTest.java
@AfterClass public static void destroy() throws Exception { server.stop();/*from w w w . j ava2s . com*/ // Delete the temporary files created for testing against the real file system. Files.walkFileTree(tmpDir.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; } }); }