boolean processDirectory ( String dirname , Collection < String > classNames ) throws IOException { if ( ! Files . isDirectory ( Paths . get ( dirname ) ) ) { err . printf ( "%s: not a directory%n" , dirname ) ; return false ; } classPath . add ( 0 , new File ( dirname ) ) ; if ( classNames . isEmpty ( ) ) { Path base = Paths . get ( dirname ) ; int baseCount = base . getNameCount ( ) ; try ( Stream < Path > paths = Files . walk ( base ) ) { Stream < String > files = paths . filter ( p -> p . getNameCount ( ) > baseCount ) . map ( p -> p . subpath ( baseCount , p . getNameCount ( ) ) ) . map ( Path :: toString ) ; return doFileNames ( files ) ; } } else { return doClassNames ( classNames ) ; } }
Processes named class files in the given directory . The directory should be the root of a package hierarchy . If classNames is empty walks the directory hierarchy to find all classes .