FileBrowserService { public File findFileInPath(File directory, String filename, boolean recursive) { if (!directory.isDirectory()) { String msg = String.format("Expected a directory but instead got '%s'", directory.getAbsolutePath()); throw new UnsupportedOperationException(msg); } File[] files = directory.listFiles(); for (File file : files) { if (file.isDirectory() && recursive) { File returnedFile = findFileInPath(file, filename, recursive); if (returnedFile != null) { return returnedFile; } } else { if (file.getName().equals(filename)) { return file; } } } return null; }  String[] getFolders(File directory); File findFileInPath(File directory, String filename, boolean recursive); String decodeDirectoryUrl(String url, String rootDirectory); String separatorsToSystem(String path); String separatorsToWindows(String path); String separatorsToUnix(String path);  }
@Test public void testFindFileInPath() throws Exception { File foundFile = testling.findFileInPath(tmpDir, tmpFile.getName(), true); Assert.assertNotNull(foundFile); Assert.assertEquals(foundFile.getAbsolutePath(), tmpFile.getAbsolutePath()); foundFile = testling.findFileInPath(tmpDir, tmpFile.getName() + "_", true); Assert.assertNull(foundFile); }