### Question:
FileFinder { public static File findFile(File rootDir, final String fileName) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.equals(fileName); } }; return findFile(rootDir, filter); } private  FileFinder(); static File findFile(File rootDir, final String fileName); static File findFile(File rootDir, FilenameFilter filter);  }### Answer:
@Test public void findFileInTree() { File rootDir = new File("src/main/java"); File file = FileFinder.findFile(rootDir, "FileFinder.java"); assertFilePath(file, "src/main/java/org/ops4j/pax/exam/spi/war/FileFinder.java"); }
@Test public void findFileInRoot() { File rootDir = new File("src/main/java/org/ops4j/pax/exam/spi/war"); File file = FileFinder.findFile(rootDir, "FileFinder.java"); assertFilePath(file, "src/main/java/org/ops4j/pax/exam/spi/war/FileFinder.java"); }
@Test public void findFileWithFilter() { File rootDir = new File("src/main/java/"); FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("Zip"); } }; File file = FileFinder.findFile(rootDir, filter); assertFilePath(file, "src/main/java/org/ops4j/pax/exam/spi/war/ZipBuilder.java"); }
@Test public void findDirectory() { File rootDir = new File("src"); File file = FileFinder.findFile(rootDir, "java"); assertFilePath(file, "src/main/java"); }
@Test public void findSubdirectory() { File rootDir = new File("src/test"); File file = FileFinder.findFile(rootDir, "java"); assertFilePath(file, "src/test/java"); }