public static Set < Class < ? > > getFromDirectory ( final ClassLoader loader , final File directory , final String packageName , final boolean mapSubPackages ) throws ClassNotFoundException { final Set < Class < ? > > classes = new HashSet < Class < ? > > ( ) ; if ( directory . exists ( ) ) { for ( final String file : getFileNames ( directory , packageName , mapSubPackages ) ) { if ( file . endsWith ( ".class" ) ) { final String name = stripFilenameExtension ( file ) ; final Class < ? > clazz = Class . forName ( name , true , loader ) ; classes . add ( clazz ) ; } } } return classes ; }
Returns the classes in a package found in a directory