public static boolean postOrderTraversal ( File root , FileVisitor visitor ) throws Exception { if ( root . isDirectory ( ) ) { for ( File child : root . listFiles ( ) ) { if ( ! postOrderTraversal ( child , visitor ) ) { return false ; } } } return visitor . visit ( root ) ; }
Walks a directory tree using post - order traversal . The contents of a directory are visited before the directory itself is visited .