PackageScanner { public static Set<String> scan(File sourceDirectory) { Set<String> packages = new HashSet<String>(); File[] directories = sourceDirectory.listFiles(new FileFilter() { @Override public boolean accept(File f) { return f != null && f.isDirectory(); } }); if (directories != null) { for (File dir : directories) { scanPackageInner(dir, null, packages); } } return packages; }  static Set<String> scan(File sourceDirectory);  }
@Test public void test() { Set<String> packages = PackageScanner.scan(new File("examples/struts2/src/main/java")); String[] pkgArray = packages.toArray(new String[1]); assertEquals(1, pkgArray.length); }