public static List < BufferedImage > loadImages ( String directory , final String regex ) { List < String > paths = UtilIO . listByRegex ( directory , regex ) ; List < BufferedImage > ret = new ArrayList <> ( ) ; if ( paths . size ( ) == 0 ) return ret ; // Sort so that the order is deterministic Collections . sort ( paths ) ; for ( String path : paths ) { BufferedImage img = loadImage ( path ) ; if ( img != null ) ret . add ( img ) ; } return ret ; }
Loads all the image in the specified directory which match the provided regex