@Test public void testGetAllFiles() { final File[] f1 = DirUtil.getAllFiles(new File("./src/test/resources/foo"), null); assertEquals(4, f1.length); final File[] f2 = DirUtil.getAllFiles(new File("./src/test/resources/foo"), new String[] {"bar"}); assertEquals(3, f2.length); final File[] f3 = DirUtil.getAllFiles(new File("./src/test/resources/foo"), new String[] {"bar", "baz"}); assertEquals(2, f3.length); }
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()]); }
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()]); } }
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()]); }  }
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()]); }  static final boolean containsFile(final File _dir, final String _filename); static File[] getAllFiles(final File _dir, final String[] _ignore); static File unzip(final File _zip, File _out_dir); static boolean isBelowDestinationPath(Path _destination_path, String _entry_name); static Set<Path> filterSubpaths(
      Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths); static String getDigest(final File _dir, final String[] _ignore, DigestAlgorithm _alg); }
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()]); }  static final boolean containsFile(final File _dir, final String _filename); static File[] getAllFiles(final File _dir, final String[] _ignore); static File unzip(final File _zip, File _out_dir); static boolean isBelowDestinationPath(Path _destination_path, String _entry_name); static Set<Path> filterSubpaths(
      Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths); static String getDigest(final File _dir, final String[] _ignore, DigestAlgorithm _alg);  }