// @topic T11923 Recursive dir traversal with Files.walkFileTree and DirectoryStream // @brief class DirectoryVisitor extends SimpleFileVisitor package week13; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; public class DirectoryVisitor extends SimpleFileVisitor< Path> { @Override////////////////////////////////////////////// public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException { //Invoked for a file in a directory. AppMain.printFileInfo(file); System.out.println(); return FileVisitResult.CONTINUE; }//visitFile @Override////////////////////////////////////////////// public FileVisitResult visitFileFailed( Path file, IOException exc ) throws IOException { System.out.println( "*** Error file [" + file.toString() + "] could not be visited"); //Invoked for a file that could not be visited. } return FileVisitResult.CONTINUE; }//visitFileFailed }//class DirectoryVisitor