Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*I'm trying to make a program that prints all the files on your computer using Files.walkFileTree. It kinda works but before it can finish it trys to access c:\Documents and Settings and throws a AccessDeniedException. How can I prevent this?*/
- public static void main(String[] args) {
- try {
- final long start = System.nanoTime();
- Files.walkFileTree(Paths.get("c:/"), new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(Path path, BasicFileAttributes attributes) throws IOException {
- System.out.println(path.toFile().getName());
- return FileVisitResult.CONTINUE;
- }
- });
- System.out.println("Finished in: " + (System.nanoTime() - start));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment