MCPcopy Index your code
hub / github.com/Afant1/JavaSearchTools / searchDir

Method searchDir

SearchClassInJar.java:29–62  ·  view source on GitHub ↗
(String dir, boolean recurse)

Source from the content-addressed store, hash-verified

27 }
28 //递归搜索目录和子目录下所有jar和zip文件
29 protected void searchDir(String dir, boolean recurse) {
30 try {
31 File d = new File(dir);
32 if (!d.isDirectory()) {
33 return;
34 }
35 File[] files = d.listFiles();
36 for (int i = 0; i < files.length; i++) {
37 if (recurse && files[i].isDirectory()) {
38 searchDir(files[i].getAbsolutePath(), true);
39 } else {
40 String filename = files[i].getAbsolutePath();
41 if (filename.endsWith(".jar")||filename.endsWith(".zip")) {
42 System.out.println("---------------------扫描"+filename+"中----------------------------");
43 ZipFile zip = new ZipFile(filename);
44 Enumeration entries = zip.entries();
45 while (entries.hasMoreElements()) {
46 ZipEntry entry = (ZipEntry) entries.nextElement();
47 String thisClassName = getClassName(entry);
48 if (wildcardEquals(this.className.toLowerCase(),thisClassName.toLowerCase()) || wildcardEquals(this.className.toLowerCase() + ".class",thisClassName.toLowerCase())) {
49 JarFileReader jarFileReader = new JarFileReader();
50 className_temp = "/"+thisClassName.replaceAll("\.","/");
51 className_final = className_temp.substring(0,className_temp.length()-5)+".java";
52 jarFileReader.Test(filename,className_final);
53 totalNum++;
54 }
55 }
56 }
57 }
58 }
59 } catch (Exception e) {
60 e.printStackTrace();
61 }
62 }
63 //通配符匹配
64 private boolean wildcardEquals(String wildcard, String str) {
65 String regRule = WildcardToReg(wildcard);

Callers 1

searchClassMethod · 0.95

Calls 3

getClassNameMethod · 0.95
wildcardEqualsMethod · 0.95
TestMethod · 0.95

Tested by

no test coverage detected