public static List < File > getResourcesInnPackage ( String root ) { try { logger . debug ( "getResourcesInnPackage for package: " + root ) ; ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; URL url = loader . getResource ( root ) ; if ( url != null ) { logger . debug ( " URL :" + url . toURI ( ) ) ; InputStream in = loader . getResourceAsStream ( root ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( in ) ) ; String resource ; List < File > fileNames = new ArrayList <> ( ) ; while ( ( resource = br . readLine ( ) ) != null ) { if ( ! root . endsWith ( "/" ) ) { root += "/" ; } String resourcePath = root + resource ; logger . debug ( "Processing resource path:" + resourcePath ) ; File file = new File ( loader . getResource ( resourcePath ) . toURI ( ) ) ; if ( file . isDirectory ( ) ) { fileNames . addAll ( getResourcesInnPackage ( resourcePath + "/" ) ) ; } else { logger . debug ( "Adding file :" + file . getName ( ) ) ; fileNames . add ( file ) ; } } return fileNames ; } else { logger . debug ( "Package not found, return empty list" ) ; return Collections . emptyList ( ) ; } } catch ( Exception e ) { JK . throww ( e ) ; return null ; } }
Gets the resources inn package .