码迷,mamicode.com
首页 > 编程语言 > 详细

java查找重复类/jar包/普通文件

时间:2014-06-24 22:14:17      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

开发web应用时,有时更新了类却没有生效,其实是因为jboss/tomcat中其他发布包下有同名类(包括全路径都相同)。

于是萌发了做个程序来检查指定目录是否存在重复类(通过asm从类文件中取类的全路径),扩展开来,还支持查找重复的文件(按文件md5进行比较),重复的jar文件。

主要代码如下:

简单测试代码:

package cn.jerryhouse.util.dup_files.test;

import java.io.File;

import org.junit.Test;

import cn.jerryhouse.util.dup_files.ClassDupFinder;
import cn.jerryhouse.util.dup_files.FileDupFinder;
import cn.jerryhouse.util.dup_files.JarFileDupFinder;

public class DupTest {

	@Test
	public void testJarFiles() {
		try {
			File[] files = new File[1];
			files[0] = new File("E:\\workspace\\yinxing");
			JarFileDupFinder dupFinder = new JarFileDupFinder();
			dupFinder.iterDirs(files);
			dupFinder.analyseResult();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@Test
	public void testFileDup() {
		try {
			File[] files = new File[1];
			files[0] = new File("E:\\workspace\\yinxing");
			FileDupFinder classDupFinder = new FileDupFinder();
			classDupFinder.iterDirs(files);
			classDupFinder.analyseResult();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void testClassDup() {
		try {
			File[] files = new File[1];
			files[0] = new File("E:\\workspace\\yinxing");
			ClassDupFinder classDupFinder = new ClassDupFinder();
			classDupFinder.iterDirs(files);
			classDupFinder.analyseResult();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


}

注:依赖jar包asm.jar。




java查找重复类/jar包/普通文件,布布扣,bubuko.com

java查找重复类/jar包/普通文件

标签:style   class   blog   code   java   http   

原文地址:http://blog.csdn.net/u014569459/article/details/33804851

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!