How to Visit a file tree - Java File Path IO

Java examples for File Path IO:Directory

Introduction

FileVisitResult contains four enum constants:

  • FileVisitResult.CONTINUE: traversal process should continue.
  • FileVisitResult.SKIP_SIBLINGS: traversal process should continue without visiting the siblings of this file or directory.
  • FileVisitResult.SKIP_SUBTREE: traversal process should continue without visiting the rest of the entries in this directory.
  • FileVisitResult.TERMINATE: traversal process should terminate.

The constants of this enum type can be iterated as follows:

Demo Code

import java.nio.file.FileVisitResult;

public class Main {
  public static void main(String[] args) throws Exception {
    for (FileVisitResult constant : FileVisitResult.values())
      System.out.println(constant);
  }//  w w  w . j  a va2 s. c  om
}

Result


Related Tutorials