public static String[] lsFiles(String directory,FilenameFilter filter) throws IOException {
  File dir=new File(directory);
  ArrayList<String> files=new ArrayList<>();
  for (  File filepath : dir.listFiles(filter)) {
    if (isFile(filepath.getAbsolutePath()))     files.add(filepath.getAbsolutePath());
  }
  return files.toArray(new String[files.size()]);
}

public static String [ ] lsFiles ( String directory , FilenameFilter filter ) throws IOException { File dir = new File ( directory ) ; ArrayList < String > files = new ArrayList < > ( ) ; for ( File filepath : dir . listFiles ( filter ) ) { if ( isFile ( filepath . getAbsolutePath ( ) ) ) files . add ( filepath . getAbsolutePath ( ) ) ; } return files . toArray ( new String [ files . size ( ) ] ) ; }
filters the files contained in a directory .
