java.nio.file.FileVisitResult Java Examples

The following examples show how to use java.nio.file.FileVisitResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CertificateManager.java    From Launcher with GNU General Public License v3.0 6 votes vote down vote up
public void readTrustStore(Path dir) throws IOException, CertificateException {
    if (!IOHelper.isDir(dir)) {
        Files.createDirectories(dir);
        try (OutputStream outputStream = IOHelper.newOutput(dir.resolve("GravitCentralRootCA.crt"));
             InputStream inputStream = IOHelper.newInput(IOHelper.getResourceURL("pro/gravit/launchserver/defaults/GravitCentralRootCA.crt"))) {
            IOHelper.transfer(inputStream, outputStream);
        }
    }
    List<X509Certificate> certificates = new ArrayList<>();
    CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
    IOHelper.walk(dir, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            if (file.toFile().getName().endsWith(".crt")) {
                try (InputStream inputStream = IOHelper.newInput(file)) {
                    certificates.add((X509Certificate) certFactory.generateCertificate(inputStream));
                } catch (CertificateException e) {
                    throw new IOException(e);
                }
            }
            return super.visitFile(file, attrs);
        }
    }, false);
    trustManager = new LauncherTrustManager(certificates.toArray(new X509Certificate[0]));
}
 
Example #2
Source File: EurostagDDB.java    From ipst with Mozilla Public License 2.0 6 votes vote down vote up
EurostagDDB(List<Path> ddbDirs) throws IOException {
    for (Path ddbDir : ddbDirs) {
        ddbDir = readSymbolicLink(ddbDir);
        if (!Files.exists(ddbDir) && !Files.isDirectory(ddbDir)) {
            throw new IllegalArgumentException(ddbDir + " must exist and be a dir");
        }
        Files.walkFileTree(ddbDir, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                String fileName = file.getFileName().toString();
                Path tmpfile = readSymbolicLink(file);
                if (Files.isDirectory(tmpfile)) {
                    Files.walkFileTree(tmpfile, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, this);
                } else if (Files.isRegularFile(tmpfile) && fileName.endsWith(".tg")) {
                    String key = fileName.substring(0, fileName.length() - 3);
                    if (generators.containsKey(key)) {
                        LOGGER.warn("the processing has detected that the file {} is present in {} and {}", fileName, tmpfile, generators.get(key));
                    }
                    generators.put(key, tmpfile);
                }
                return super.visitFile(file, attrs);
            }
        });
    }
}
 
Example #3
Source File: AbstractDeploymentManagerTest.java    From wildfly-maven-plugin with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void deletePath(final Path path) throws IOException {
    if (Files.isDirectory(path)) {
        Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
                Files.deleteIfExists(file);
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
                Files.deleteIfExists(dir);
                return FileVisitResult.CONTINUE;
            }
        });
    } else {
        Files.deleteIfExists(path);
    }
}
 
Example #4
Source File: SearchFileVisitor.java    From JavaRushTasks with MIT License 6 votes vote down vote up
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
    if (!attrs.isRegularFile()) return CONTINUE;

    if (partOfNameCheck && file.getFileName().toString().indexOf(this.partOfName) == -1)
        return CONTINUE;

    if (minSizeCheck && attrs.size() < minSize)
        return CONTINUE;

    if (maxSizeCheck && attrs.size() > maxSize)
        return CONTINUE;

    if (partOfContentCheck && new String(Files.readAllBytes(file)).indexOf(partOfContent) == -1)
        return CONTINUE;

    foundFiles.add(file);

    return CONTINUE;
}
 
Example #5
Source File: TakeDownIT.java    From airfield with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws IOException {
    Path directory = Paths.get(LOCAL_REPO);
    if (Files.exists(directory)) {
        Files.walkFileTree(directory, 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;
            }

        });
    }
    this.cut = new TakeDown(LOCAL_REPO, "git://localhost:4242/");
}
 
Example #6
Source File: FileSynchronizeService.java    From jweb-cms with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException {
    String filePath = file.toString().replaceAll("\\\\", "/");
    filePath = filePath.replace(prefix, "");
    Optional<app.jweb.file.domain.File> optional = fileService.findByPath(filePath);
    if (!optional.isPresent()) {
        File realFile = file.toFile();
        String directoryPath = parent(filePath);
        CreateFileRequest createFileRequest = new CreateFileRequest();
        createFileRequest.directoryId = map.get(directoryPath).id;
        createFileRequest.path = filePath;
        createFileRequest.length = realFile.length();
        createFileRequest.fileName = realFile.getName();
        createFileRequest.requestBy = "synchronized";
        fileService.create(createFileRequest);
    }
    return FileVisitResult.CONTINUE;
}
 
Example #7
Source File: IterationCount.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void deleteDir(Path directory) throws IOException {
    Files.walkFileTree(directory, 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;
        }
    });
}
 
Example #8
Source File: ZipUtilsWriteTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@AfterMethod
public void tearDown() throws IOException {
  Files.delete(zipFile);
  Files.walkFileTree(
      tempDir,
      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 e) throws IOException {
          if (e == null) {
            Files.delete(dir);
            return FileVisitResult.CONTINUE;
          } else {
            throw e;
          }
        }
      });
}
 
Example #9
Source File: WSDLToIDLTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@After
public void tearDown() throws Exception {
    super.tearDown();

    Files.walkFileTree(output, 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;
        }
    });
    output = null;
}
 
Example #10
Source File: DirectoryHelper.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Empties an existing directory, by recursively removing all it's siblings, regular files and directories. Accepts
 * only existing directories, and when returns, it's guaranteed that passed in directory will be emptied (will
 * have no siblings, not counting OS specific ones, will be "empty" as per current OS is empty defined).
 */
public static void empty(final Path dir) throws IOException {
  validateDirectory(dir);
  Files.walkFileTree(dir, DEFAULT_FILE_VISIT_OPTIONS, Integer.MAX_VALUE,
      new SimpleFileVisitor<Path>()
      {
        @Override
        public FileVisitResult visitFile(final Path f, final BasicFileAttributes attrs) throws IOException {
          Files.delete(f);
          return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult postVisitDirectory(final Path d, final IOException exc) throws IOException {
          if (exc != null) {
            throw exc;
          }
          else if (dir != d) {
            Files.delete(d);
          }
          return FileVisitResult.CONTINUE;
        }
      }
  );
}
 
Example #11
Source File: MoveFileVisitor.java    From Java-Coding-Problems with MIT License 6 votes vote down vote up
@Override
public FileVisitResult preVisitDirectory(Object dir, BasicFileAttributes attrs) throws IOException {
    
    System.out.println("Move directory: " + (Path) dir);
    
    Path newDir = moveTo.resolve(moveFrom.relativize((Path) dir));
    try {
        Files.copy((Path) dir, newDir, REPLACE_EXISTING, COPY_ATTRIBUTES);
        time = Files.getLastModifiedTime((Path) dir);
    } catch (IOException e) {
        System.err.println("Unable to move " + newDir + " [" + e + "]");
        
        return FileVisitResult.SKIP_SUBTREE;
    }

    return FileVisitResult.CONTINUE;
}
 
Example #12
Source File: AbstractWildFlyServerMojoTest.java    From wildfly-maven-plugin with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected static void deleteRecursively(final Path path) throws IOException {
    if (Files.exists(path)) {
        if (Files.isDirectory(path)) {
            Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
                    Files.deleteIfExists(file);
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
                    Files.deleteIfExists(dir);
                    return FileVisitResult.CONTINUE;
                }
            });
        } else {
            Files.deleteIfExists(path);
        }
    }
}
 
Example #13
Source File: RaftStorageTest.java    From atomix with Apache License 2.0 6 votes vote down vote up
@Before
@After
public void cleanupStorage() throws IOException {
  if (Files.exists(PATH)) {
    Files.walkFileTree(PATH, 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;
      }
    });
  }
}
 
Example #14
Source File: NugetProcessCompiler.java    From setupmaker with Apache License 2.0 6 votes vote down vote up
/**
 * Delete all files under a target directory
 * @param path: folder containing spec files
 * @throws IOException
 */
public void cleanDir(String path) throws IOException {
    Path directory = Paths.get(path);
    Files.walkFileTree(directory, 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;
        }

    });
}
 
Example #15
Source File: DefaultFilteredDirectoryCopier.java    From buck with Apache License 2.0 6 votes vote down vote up
@Override
public void copyDir(ProjectFilesystem filesystem, Path srcDir, Path destDir, Predicate<Path> pred)
    throws IOException {

  // Remove existing contents if any.
  if (filesystem.exists(destDir)) {
    filesystem.deleteRecursivelyIfExists(destDir);
  }
  filesystem.mkdirs(destDir);

  filesystem.walkRelativeFileTree(
      srcDir,
      new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path srcPath, BasicFileAttributes attributes)
            throws IOException {
          if (pred.test(srcPath)) {
            Path destPath = destDir.resolve(srcDir.relativize(srcPath));
            filesystem.createParentDirs(destPath);
            filesystem.copy(srcPath, destPath, CopySourceMode.FILE);
          }
          return FileVisitResult.CONTINUE;
        }
      });
}
 
Example #16
Source File: FileTesting.java    From atomix with Apache License 2.0 6 votes vote down vote up
public static void cleanFiles() {
  Path directory = Paths.get("target/test-files/");
  try {
    Files.walkFileTree(directory, 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;
      }
    });
  } catch (Exception ignore) {
  }
}
 
Example #17
Source File: TestFlowConfigurationArchiveManager.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws Exception {

    // Clean up old files.
    if (Files.isDirectory(archiveDir.toPath())) {
        Files.walkFileTree(archiveDir.toPath(), new SimpleFileVisitor<Path>(){
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Files.delete(file);
                return FileVisitResult.CONTINUE;
            }
        });
    }

    // Create original flow.xml.gz
    Files.createDirectories(flowFile.getParentFile().toPath());
    try (OutputStream os = Files.newOutputStream(flowFile.toPath(),
            StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)) {
        // 10 bytes.
        os.write("0123456789".getBytes());
    }

}
 
Example #18
Source File: FileWalker.java    From PeerWasp with MIT License 6 votes vote down vote up
@Override
public FileVisitResult visitFile(Path path, BasicFileAttributes attr) throws IOException {
	if(PathUtils.isFileHidden(path)){
		return FileVisitResult.CONTINUE;
	}
	if (throwCreates) {
		eventManager.onLocalFileCreated(path);
	} else {
		if (Files.isDirectory(path)) {
			FolderComposite newFolder = new FolderComposite(path, false);
			newFolder.setIsSynchronized(true);
			fileTree.putComponent(path, newFolder);
		} else {
			FileLeaf newFile = new FileLeaf(path, false);
			newFile.setIsSynchronized(true);
			fileTree.putComponent(path, newFile);
		}
	}

	return FileVisitResult.CONTINUE;
}
 
Example #19
Source File: BattleLogs.java    From logbook-kai with MIT License 6 votes vote down vote up
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
    // ルートディレクトリかチェック
    if (this.baseDir.equals(dir)) {
        return FileVisitResult.CONTINUE;
    }
    // 年月のフォルダかチェック
    String dirName = dir.getFileName().toString();
    if (!isExpectedDirectoryName(dirName)) {
        return FileVisitResult.SKIP_SUBTREE;
    }
    // 年月部分を比較
    if (dirName.compareTo(this.expired.substring(0, dirName.length())) > 0) {
        return FileVisitResult.SKIP_SUBTREE;
    }
    return FileVisitResult.CONTINUE;
}
 
Example #20
Source File: ApplicationRunnerServlet.java    From flow with Apache License 2.0 6 votes vote down vote up
private void addDirectories(File parent, Set<String> packages)
        throws IOException {
    Path root = parent.toPath();
    Files.walkFileTree(parent.toPath(), new SimpleFileVisitor<Path>() {

        @Override
        public FileVisitResult postVisitDirectory(Path dir, IOException exc)
                throws IOException {
            File file = dir.toFile();
            if (file.isDirectory()) {
                Path relative = root.relativize(file.toPath());
                packages.add(relative.toString().replace(File.separatorChar,
                        '.'));
            }
            return super.postVisitDirectory(dir, exc);
        }
    });
}
 
Example #21
Source File: TestUtils.java    From commerce-gradle-plugin with Apache License 2.0 6 votes vote down vote up
public static void generateDummyPlatform(Path destination, String version) throws IOException, URISyntaxException {
    Path targetZip = destination.resolve(String.format("hybris-commerce-suite-%s.zip", version));
    Map<String, String> env = new HashMap<>();
    env.put("create", "true");
    try (FileSystem zipfs = FileSystems.newFileSystem(URI.create("jar:" + targetZip.toUri().toString()), env, null)) {
        Path sourceDir = Paths.get(TestUtils.class.getResource("/dummy-platform").toURI());
        Files.walkFileTree(sourceDir, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Path relative = sourceDir.relativize(file);
                if (relative.getParent() != null) {
                    Path path = zipfs.getPath(relative.getParent().toString());
                    Files.createDirectories(path);
                }
                Path target = zipfs.getPath(relative.toString());
                Files.copy(file, target);
                return super.visitFile(file, attrs);
            }
        });
        String build = String.format("version=%s\n", version);
        Path buildNumber = zipfs.getPath("hybris", "bin", "platform", "build.number");
        Files.write(buildNumber, build.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
    }
}
 
Example #22
Source File: ConnectionInformationFileUtils.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
	if ((attrs == null ? file.toFile().isDirectory() : attrs.isDirectory()) || file.getFileName().endsWith(ConnectionInformationSerializer.MD5_SUFFIX)) {
		return FileVisitResult.CONTINUE;
	}
	// check if it already is a cache file
	if (file.startsWith(target.toString())) {
		return FileVisitResult.CONTINUE;
	}
	String md5Hash = getMD5Hex(file);
	if (md5Hash == null) {
		// skip files without valid md5
		return FileVisitResult.CONTINUE;
	}
	Path relative = source.relativize(file);
	// resolve cached file location
	Path cacheLocation = target.resolve(Paths.get(relative.toString(), md5Hash, file.getFileName().toString()));
	if (cacheLocation.toFile().exists()) {
		// cache exists, collect
		fileList.add(cacheLocation);
		return FileVisitResult.CONTINUE;
	}
	// create new cached file
	Files.createDirectories(cacheLocation.getParent());
	fileList.add(Files.copy(file, cacheLocation));
	return FileVisitResult.CONTINUE;
}
 
Example #23
Source File: RecursivePathWatcher.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private void register(Path path) throws IOException {
    Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException {
            // always include root, otherwise give a relative dir to check
            if (root.equals(dir) || pathFilter.allows(root.relativize(dir))) {
                WatchKey key = dir.register(watchService, EVENT_KINDS, HIGH_SENSITIVITY);
                keys.put(key, dir);
                dirs.put(dir, key);
                return FileVisitResult.CONTINUE;
            }
            return FileVisitResult.SKIP_SUBTREE;
        }
    });
}
 
Example #24
Source File: WsImportTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void deleteGeneratedFiles() {
    Path p = Paths.get("generated");
    if (Files.exists(p)) {
        try {
            Files.walkFileTree(p, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult visitFile(Path file,
                    BasicFileAttributes attrs) throws IOException {

                    Files.delete(file);
                    return CONTINUE;
                }
                @Override
                public FileVisitResult postVisitDirectory(Path dir,
                    IOException exc) throws IOException {

                    if (exc == null) {
                        Files.delete(dir);
                        return CONTINUE;
                    } else {
                        throw exc;
                    }
                }
            });
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}
 
Example #25
Source File: SupplementalJapaneseEraTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FileVisitResult visitFile(Path file,
        BasicFileAttributes attrs) throws IOException {
    if (!file.toFile().isFile()) {
        return FileVisitResult.CONTINUE;
    }
    Path relativePath = copyFrom.relativize(file);
    Path destination = copyTo.resolve(relativePath);
    if (relativePath.getFileName().equals(calProps)) {
        modifyCalendarProperties(file, destination);
    } else {
        Files.copy(file, destination, StandardCopyOption.COPY_ATTRIBUTES);
    }
    return FileVisitResult.CONTINUE;
}
 
Example #26
Source File: ThumbnailManager.java    From fess with Apache License 2.0 5 votes vote down vote up
@Override
public FileVisitResult postVisitDirectory(final Path dir, final IOException e) throws IOException {
    if (e != null) {
        logger.warn("I/O exception on " + dir, e);
    }
    deleteEmptyDirectory(dir);
    return FileVisitResult.CONTINUE;
}
 
Example #27
Source File: AnalysisRunner.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a jar file which contains all resource files. This is necessary to
 * let {@link Plugin#loadCustomPlugin(File, Project)} load custom plugin to
 * test.
 *
 * @return a {@link File} instance which represent generated jar file
 * @throws IOException
 * @throws URISyntaxException
 */
private static File createTempJar() throws IOException, URISyntaxException {
    ClassLoader cl = AnalysisRunner.class.getClassLoader();

    URL resource = cl.getResource("findbugs.xml");
    URI uri = resource.toURI();

    if ("jar".equals(uri.getScheme())) {
        JarURLConnection connection = (JarURLConnection) resource.openConnection();
        URL url = connection.getJarFileURL();
        return new File(url.toURI());
    }

    Path tempJar = File.createTempFile("SpotBugsAnalysisRunner", ".jar").toPath();
    try (OutputStream output = Files.newOutputStream(tempJar, StandardOpenOption.WRITE);
            JarOutputStream jar = new JarOutputStream(output)) {
        Path resourceRoot = Paths.get(uri).getParent();

        byte[] data = new byte[4 * 1024];
        Files.walkFileTree(resourceRoot, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                String name = resourceRoot.relativize(file).toString();
                jar.putNextEntry(new ZipEntry(name));
                try (InputStream input = Files.newInputStream(file, StandardOpenOption.READ)) {
                    int len;
                    while ((len = input.read(data)) > 0) {
                        jar.write(data, 0, len);
                    }
                }
                return FileVisitResult.CONTINUE;
            }
        });
    }
    return tempJar.toFile();
}
 
Example #28
Source File: JrtFsEnumeration.java    From spring-init with Apache License 2.0 5 votes vote down vote up
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
	int fnc = file.getNameCount();
	if (fnc >= 3 && file.toString().endsWith(".class")) { // There is a preceeding module name - e.g. /modules/java.base/java/lang/Object.class
		// file.subpath(2, fnc); // e.g. java/lang/Object.class
		jfos.add(new JrtEntryJavaFileObject(file));
	}
	return FileVisitResult.CONTINUE;
}
 
Example #29
Source File: TreeRemover.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public FileVisitResult postVisitDirectory (Path dir,
                                           IOException ex)
        throws IOException
{
    if (ex == null) {
        logger.debug("Deleting directory {}", dir);
        Files.delete(dir);

        return FileVisitResult.CONTINUE;
    } else {
        // directory iteration failed
        throw ex;
    }
}
 
Example #30
Source File: LogFileService.java    From c5-replicator with Apache License 2.0 5 votes vote down vote up
/**
 * Delete all the logs stored in the wal root directory.
 *
 * @throws IOException
 */
public void clearAllLogs() throws IOException {
  Files.walkFileTree(logRootDir, new SimpleFileVisitor<Path>() {
    @Override
    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
      if (!attrs.isDirectory()) {
        Files.delete(file);
      }
      return FileVisitResult.CONTINUE;
    }
  });
}