@Test(expected=FileNotFoundException.class) public void findFilesThrowsException0() throws Exception { FileUtil.findFiles(new File("target/samplelogs2"), null); }
public static File[] findFiles(File dir, FileFilter filter) throws FileNotFoundException { if (!dir.exists()) { throw new FileNotFoundException("Directory " + dir + " does not exist."); } if (!dir.isDirectory()) { throw new FileNotFoundException("File " + dir + " is not a directory."); } ArrayList<File> files = new ArrayList<File>(); File[] allFiles = dir.listFiles(); if (allFiles != null && allFiles.length > 0) { for (File f : allFiles) { if (f.isFile()) { if (filter.accept(f)) { files.add(f); } } } } File[] r = files.toArray(new File[0]); Arrays.sort(r); return r; }
FileUtil { public static File[] findFiles(File dir, FileFilter filter) throws FileNotFoundException { if (!dir.exists()) { throw new FileNotFoundException("Directory " + dir + " does not exist."); } if (!dir.isDirectory()) { throw new FileNotFoundException("File " + dir + " is not a directory."); } ArrayList<File> files = new ArrayList<File>(); File[] allFiles = dir.listFiles(); if (allFiles != null && allFiles.length > 0) { for (File f : allFiles) { if (f.isFile()) { if (filter.accept(f)) { files.add(f); } } } } File[] r = files.toArray(new File[0]); Arrays.sort(r); return r; } }
FileUtil { public static File[] findFiles(File dir, FileFilter filter) throws FileNotFoundException { if (!dir.exists()) { throw new FileNotFoundException("Directory " + dir + " does not exist."); } if (!dir.isDirectory()) { throw new FileNotFoundException("File " + dir + " is not a directory."); } ArrayList<File> files = new ArrayList<File>(); File[] allFiles = dir.listFiles(); if (allFiles != null && allFiles.length > 0) { for (File f : allFiles) { if (f.isFile()) { if (filter.accept(f)) { files.add(f); } } } } File[] r = files.toArray(new File[0]); Arrays.sort(r); return r; } private  FileUtil(); }
FileUtil { public static File[] findFiles(File dir, FileFilter filter) throws FileNotFoundException { if (!dir.exists()) { throw new FileNotFoundException("Directory " + dir + " does not exist."); } if (!dir.isDirectory()) { throw new FileNotFoundException("File " + dir + " is not a directory."); } ArrayList<File> files = new ArrayList<File>(); File[] allFiles = dir.listFiles(); if (allFiles != null && allFiles.length > 0) { for (File f : allFiles) { if (f.isFile()) { if (filter.accept(f)) { files.add(f); } } } } File[] r = files.toArray(new File[0]); Arrays.sort(r); return r; } private  FileUtil(); static boolean equals(File file1, File file2); static boolean isValidFileExtension(String extension); static String parseFileExtension(String filename); static File[] findFiles(File dir, FileFilter filter); static void copy(File sourceFile, File targetFile); static boolean copy(File sourceFile, File targetFile, boolean overwrite); }
FileUtil { public static File[] findFiles(File dir, FileFilter filter) throws FileNotFoundException { if (!dir.exists()) { throw new FileNotFoundException("Directory " + dir + " does not exist."); } if (!dir.isDirectory()) { throw new FileNotFoundException("File " + dir + " is not a directory."); } ArrayList<File> files = new ArrayList<File>(); File[] allFiles = dir.listFiles(); if (allFiles != null && allFiles.length > 0) { for (File f : allFiles) { if (f.isFile()) { if (filter.accept(f)) { files.add(f); } } } } File[] r = files.toArray(new File[0]); Arrays.sort(r); return r; } private  FileUtil(); static boolean equals(File file1, File file2); static boolean isValidFileExtension(String extension); static String parseFileExtension(String filename); static File[] findFiles(File dir, FileFilter filter); static void copy(File sourceFile, File targetFile); static boolean copy(File sourceFile, File targetFile, boolean overwrite);  }