w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to use Java to Index entire hard drive / filesystem?

To me this looks like a duplicate of Monitor subfolders with a Java watch service

You can watch subdirectories like this:

/**
 * Register the given directory, and all its sub-directories, with the
WatchService.
 */
private void registerAll(final Path start) throws IOException {
    // register directory and sub-directories
    Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult preVisitDirectory(Path dir,
BasicFileAttributes attrs)
            throws IOException {
                dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE,
ENTRY_MODIFY);
                return FileVisitResult.CONTINUE;
        }
    });
}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.