private static List < File > findFiles ( final File parent , boolean recurse ) { final List < File > result = new ArrayList <> ( ) ; if ( parent . isDirectory ( ) ) { File [ ] files = parent . listFiles ( ) ; files = ( files != null ? files : new File [ 0 ] ) ; for ( File child : files ) { if ( child . isFile ( ) && child . getName ( ) . endsWith ( ".java" ) ) { result . add ( child ) ; } } if ( recurse ) { for ( File child : files ) { if ( child . isDirectory ( ) && child . getName ( ) . startsWith ( "." ) == false ) { result . addAll ( findFiles ( child , recurse ) ) ; } } } } else { if ( parent . getName ( ) . endsWith ( ".java" ) ) { result . add ( parent ) ; } } return result ; }
Finds the set of files to process .