class DirUtil {

  public static File[] getAllFiles(final File _dir, final String[] _ignore) {
    if (!_dir.isDirectory())
      throw new IllegalArgumentException("[" + _dir + "] is not a directory");

    final List<File> list = new ArrayList<File>();

    final File[] files = _dir.listFiles();
    if (files != null) {
      Arrays.sort(files);
      outer:
      for (final File file : files) {
        if (file.isDirectory()) {
          list.addAll(Arrays.asList(DirUtil.getAllFiles(file, _ignore)));
          list.add(file);
        } else {
          if (_ignore != null) {
            for (String ext : _ignore) {
              if (file.getName().endsWith(ext)) {
                continue outer;
              }
            }
          }
          list.add(file);
        }
      }
    }
    return list.toArray(new File[list.size()]);
  }

}