public static List<String> fileList(String directoryPath,boolean includeFullPath){
  List<String> fileList=new ArrayList<String>();
  String dir=directoryPath.substring(0,directoryPath.lastIndexOf(File.separator));
  String pattern=StringUtils.substringAfterLast(directoryPath,File.separator);
  File directory=new File(dir);
  if (directory.isDirectory()) {
    File[] files=directory.listFiles();
    for (int i=0; i < files.length; i++) {
      File f=files[i];
      if (f.isFile()) {
        String fileName=f.getName();
        String fullPath=dir + File.separator + fileName;
        if (fileName.matches(convertGlobToRegEx(pattern))) {
          if (includeFullPath) {
            fileList.add(fullPath);
          }
 else {
            fileList.add(fileName);
          }
        }
      }
    }
  }
  return fileList;
}

public static List < String > fileList ( String directoryPath , boolean includeFullPath ) { List < String > fileList = new ArrayList < String > ( ) ; String dir = directoryPath . substring ( 0 , directoryPath . lastIndexOf ( File . separator ) ) ; String pattern = StringUtils . substringAfterLast ( directoryPath , File . separator ) ; File directory = new File ( dir ) ; if ( directory . isDirectory ( ) ) { File [ ] files = directory . listFiles ( ) ; for ( int i = 0 ; i < files . length ; i ++ ) { File f = files [ i ] ; if ( f . isFile ( ) ) { String fileName = f . getName ( ) ; String fullPath = dir + File . separator + fileName ; if ( fileName . matches ( convertGlobToRegEx ( pattern ) ) ) { if ( includeFullPath ) { fileList . add ( fullPath ) ; } else { fileList . add ( fileName ) ; } } } } } return fileList ; }
returns a listing of files in a directory matching a pattern .
