package test; import org.jeecg.common.util.MD5Util; import java.io.File; public class FileTest { public static void main(String[] args) { String path = "//192.168.0.9/研发技术文档"; checkFile(path); } public static void checkFile(String path) { File file = new File(path); if (!file.exists()) { System.err.println("文件不存在!!"); } File[] files = file.listFiles(); if (files != null && files.length != 0) { for (int i = 0; i < files.length; i++) { File f = files[i]; if (!"#recycle".equals(f.getName()) && !"$RECYCLE.BIN".equals(f.getName()) && !"System Volume Information".equals(f.getName())) { if (f.isDirectory()) { System.out.println(f.getPath()); checkFile(f.getPath()); } else { try { String md5 = MD5Util.getFileMD5(f); String fileName = ""; int lastIndex = f.getName().lastIndexOf("."); if (lastIndex <0) { fileName = f.getName(); } else { fileName = f.getName().substring(0, lastIndex); } if (!fileName.equals(md5)) { System.out.println( fileName); System.out.println(md5); } }catch (Exception e) { System.out.println("文件名:【" + f.getName()+"】"); e.printStackTrace(); } } } } } } }