摘要: 领导要求测试也要学习开发技术,这是我第一个关于测试的小程序,检测冲突的jar包冲突的class,有时候我们用高版本的jar包,低版本jar包中有同样路径的class文件,就会报冲突,有了这个小程序,就解决了这个问题 ...
领导要求测试也要学习开发技术,这是我第一个关于测试的小程序,检测冲突的jar包冲突的class,有时候我们用高版本的jar包,低版本jar包中有同样路径的class文件,就会报冲突,有了这个小程序,就解决了这个问题。这是我第一个小程序,希望能慢慢开发出测试工具,加油,我给自己带盐。public class Testclass { |
public static void main(String[] args) throws IOException {/*if(args.length < 1){System.out.println("请输入jar包路径!");return;}*///File file = new File(args[0]);File file = new File("D:lib");Map<String,HashSet<String> > jarMap = new HashMap<String,HashSet<String>>();String values;if(null != file && file.exists() && file.isDirectory()){File[] jarFile = file.listFiles();for(File f : jarFile){if(f.isFile() && f.getName().endsWith(".jar")){ //是文件夹且以.jar结尾try {JarFile jar = new JarFile(f);Enumeration<JarEntry> enumJar = jar.entries();//System.out.println("777");while(enumJar.hasMoreElements()){//System.out.println("666");JarEntry je = enumJar.nextElement();// System.out.println("999");if(je.getName().endsWith(".class")){ //以.class结尾//System.out.println("000");if(jarMap.containsKey(je.getName())){ //若存在拥有key的元素,则返回truejarMap.get(je.getName()).add(f.getName());System.out.println("kdfjldsjfdlsjf "+je.getName());}else{HashSet<String> set = new HashSet<String>();//// System.out.println("22222"+f.getName());set.add(f.getName());jarMap.put(je.getName(), set); //填写一个set元素的key值/// System.out.println(je.getName());// System.out.println(jarMap.size());//System.out.println("111");/*if(jarMap.get(je.getName()).size()>1){System.out.println("重复类");}*/}//System.out.println(jarMap.get(je.getName()).size());}//System.out.println(jarMap.size());// System.out.println(jarMap.get(je.getName()).size());}}finally{}}}