[Java]检查一下类冲突

static void t5(){
		File jarDir = new File("D:\\shanl-works\\edass4a_2012\\app_zsh\\lib");
//		File jarDir = new File("D:\\shanl-works\\edass4a_2012\\zhujifanghu_zsh\\code\\WebRoot\\WEB-INF\\lib");
		HashMap<String,String> dicts = new HashMap<String,String>();
			
		File[] jars = jarDir.listFiles(new FilenameFilter(){
			@Override
			public boolean accept(File dir, String name) {
				return name.endsWith(".jar");				
			}			
		});		
		
		for(File f: jars){
			try {
				JarFile jar = new JarFile(f);
				Enumeration<JarEntry> items = jar.entries();
				while(items.hasMoreElements()){
					JarEntry i = items.nextElement();					
					if(i.getName().endsWith(".class")){
						if(!dicts.containsKey(i.getName())){
							dicts.put(i.getName(), f.getName());
						}else{
							System.out.println(i.getName()+"\t"+f.getName()+"\t"+dicts.get(i.getName()));
						}
					}				
				}
			} catch (IOException e) {			
				e.printStackTrace();
			}
		}	
	}


你可能感兴趣的:([Java]检查一下类冲突)