private void findFiles ( File directory ) throws IOException , ClassNotFoundException { File [ ] files = directory . listFiles ( new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { return name . endsWith ( ".class" ) ; } } ) ; if ( files != null ) { for ( File file : files ) { int current = currentDirectoryPath . length ( ) ; String fileName = file . getCanonicalPath ( ) . substring ( ++ current ) ; String className = fileName . replace ( File . separatorChar , ' ' ) . substring ( 0 , fileName . length ( ) - 6 ) ; tryClass ( className ) ; } } }
This will scan directory for class files non - recursive .