List of usage examples for java.nio.file Files delete
public static void delete(Path path) throws IOException
From source file:DeleteDirectory.java
@Override public FileVisitResult postVisitDirectory(Path directory, IOException exception) throws IOException { if (exception == null) { System.out.println("Deleting " + directory.getFileName()); Files.delete(directory); return FileVisitResult.CONTINUE; } else {//w w w . j av a 2 s . c o m throw exception; } }
From source file:io.logspace.it.InfrastructureRule.java
private static void deleteFile(Path path) { try {/*from w w w .j a v a 2 s. c om*/ Files.delete(path); } catch (Exception e) { throw new LogspaceTestException("Error while deleting file '" + path + "'.", e); } }
From source file:com.github.ffremont.microservices.springboot.node.tasks.AbstractInstallTest.java
private void remove(Path path) throws IOException { Files.list(path).forEach(item -> { try {/*from w w w . ja v a 2 s . c o m*/ if (Files.isDirectory(item)) { this.remove(item); } Files.delete(item); } catch (IOException e) { LOG.error("Impossible de nettoyer", e); } }); }
From source file:download.XBRLFileCleaner.java
/** * Deletes all non xbrl file in the, master directory * * @throws java.io.IOException//from ww w. j a va 2 s .com */ public void deleteNonXBRLFiles() throws IOException { File masterDirectory = new File(XBRLFilePaths.XBRL_FILING_DIRECTORY); // lists all files that are not directories except rfd object files Collection<File> files = FileUtils.listFiles(masterDirectory, new String[] { "zip", "xdr", "xsd", "xml" }, true); // deletes the files that are not xbrl files for (File file : files) { if (!isXBRLFile(file.getName())) { Files.delete(Paths.get(file.getAbsolutePath())); } else { file.renameTo( new File(file.getParent() + File.separatorChar + file.getParentFile().getName() + ".xml")); } } }
From source file:pl.p.lodz.ftims.server.logic.ChallengeServiceTest.java
@AfterClass public static void deleteImgDir() throws IOException { Stream<Path> stream = Files.list(Paths.get(PHOTOS_DIR)); stream.forEach((Path p) -> { try {/*w ww .ja v a 2s. c o m*/ Files.delete(p); } catch (IOException ex) { Logger.getLogger(ChallengeServiceTest.class.getName()).log(Level.SEVERE, null, ex); } }); Files.deleteIfExists(Paths.get(PHOTOS_DIR)); }
From source file:com.heliosdecompiler.helios.utils.APKTool.java
public static void decodeResources(File input, File output) { try {//from w ww . j a v a2 s .co m Path temporaryDirectory = Files.createTempDirectory("apkresources"); File directory = temporaryDirectory.toFile(); Files.delete(temporaryDirectory); cmdDecode(input, directory); File original = new File(directory, "original"); FileUtils.deleteDirectory(original); File apktool = new File(directory, "apktool.yml"); apktool.delete(); ZipUtil.pack(directory, output); FileUtils.deleteDirectory(directory); } catch (Exception e) { ExceptionHandler.handle(e); } }
From source file:org.apache.solr.hadoop.MRUnitBase.java
@AfterClass public static void teardownClass() throws Exception { if (solrHomeZip != null) Files.delete(solrHomeZip.toPath()); solrHomeZip = null;//from w ww. j av a 2s . co m }
From source file:com.github.ffremont.microservices.springboot.node.tasks.UninstallTask.java
/** * // www. j a v a 2 s . c o m * @param path * @throws IOException */ private void remove(Path path) throws IOException { Files.list(path).forEach((Path item) -> { try { if (Files.isDirectory(item)) { this.remove(item); } else { Files.delete(item); } } catch (IOException e) { LOG.error("Impossible de supprmimer les lments dans " + item.toAbsolutePath(), e); } }); Files.delete(path); }
From source file:org.jboss.jbossset.JiraReporterTest.java
@AfterClass public static void tearDown() throws Exception { Files.delete(Paths.get("", USERS_FILE_URL)); Files.delete(Paths.get("", DOMAIN_FILE_URL)); }
From source file:net.gvmtool.api.Uninstall.java
public void version(String version) { if (StringUtils.isBlank(version)) { throw new IllegalArgumentException("No valid candidate version was provided."); }//from www. j ava2s .com Path candidateDir = candidates.get(context, candidateName); if (context.candidateHasCurrentVersion(candidateDir)) { try { Files.delete(context.candidateCurrentVersion(candidateDir)); } catch (IOException e) { throw new RuntimeException("Error removing existing current symlink for candidate " + candidateName, e); } } if (context.candidateVersionInstalled(candidateDir, version) && context.candidateVersionIsDir(candidateDir, version)) { try { Files.delete(context.candidateVersionDir(candidateDir, version)); } catch (IOException e) { throw new RuntimeException("Error removing " + candidateName + " " + version, e); } } }