遍历 jdk1.7 jdk1.8 异同点

简介:      import java.io.File; import java.util.Arrays; public class CompareFileDirector { // // D:\soft\Java\jdk_1.

 

 

 

import java.io.File;
import java.util.Arrays;

public class CompareFileDirector {

//	
//	D:\soft\Java\jdk_1.8.0.0_64\bin\javapackager.exe	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\bin\jdeps.exe	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\bin\jjs.exe	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\javafx-src.zip	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\decora_sse.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\j2pkcs11.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\javafx_font.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\javafx_font_t2k.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\javafx_iio.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\jjs.exe	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\lcms.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\prism_common.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\prism_d3d.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\prism_es2.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\bin\prism_sw.dll	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\ext\cldrdata.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\ext\jfxrt.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\ext\nashorn.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\ext\sunpkcs11.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\hijrah-config-umalqura.properties	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\jfxswt.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\security\blacklisted.certs	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre\lib\tzdb.dat	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\jre.exe	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\config\Modules\org-netbeans-core-multitabs.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\config\Modules\org-netbeans-lib-uihandler.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\config\Modules\org-netbeans-modules-keyring-fallback.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\config\Modules\org-netbeans-modules-uihandler.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-core-multitabs_ja.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-core-multitabs_zh_CN.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-core-network_ja.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-core-network_zh_CN.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-lib-uihandler_ja.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-lib-uihandler_zh_CN.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-modules-keyring-fallback_ja.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-modules-keyring-fallback_zh_CN.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-modules-uihandler_ja.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\locale\org-netbeans-modules-uihandler_zh_CN.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\org-netbeans-core-multitabs.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\org-netbeans-lib-uihandler.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\org-netbeans-modules-keyring-fallback.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\modules\org-netbeans-modules-uihandler.jar	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\\update_tracking\org-netbeans-core-multitabs.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\\update_tracking\org-netbeans-lib-uihandler.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\\update_tracking\org-netbeans-modules-keyring-fallback.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\platform\\update_tracking\org-netbeans-modules-uihandler.xml	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\visualvm\config\Modules\org-netbeans-lib-uihandler.xml_hidden	false	  	 
//	D:\soft\Java\jdk_1.8.0.0_64\lib\visualvm\visualvm\config\Modules\org-netbeans-modules-uihandler.xml_hidden	false	  	 
//	========= 
//	D:\soft\Java\jdk1.7.0_72\bin\apt.exe	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\bin\decora-sse.dll	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\bin\javafx-font.dll	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\bin\javafx-iio.dll	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\bin\JdbcOdbc.dll	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\bin\libxml2.dll	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\bin\libxslt.dll	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\bin\prism-d3d.dll	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\alt-rt.jar	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\jfxrt.jar	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\launcher.exe	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\security\javafx.policy	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Africa	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\America	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Antarctica	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Asia	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Atlantic	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Australia	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\CET	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\CST6CDT	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\EET	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\EST	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\EST5EDT	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Etc	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Europe	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\GMT	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\HST	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Indian	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\MET	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\MST	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\MST7MDT	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\Pacific	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\PST8PDT	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\SystemV	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\WET	false	  	 
//	D:\soft\Java\jdk1.7.0_72\jre\lib\ZoneInfoMappings	false	  	 
//	D:\soft\Java\jdk1.7.0_72\lib\javafx-doclet.jar	false	  	 
//	D:\soft\Java\jdk1.7.0_72\lib\visualvm\platform\modules\ext\nsProxyAutoConfig.js	false	  	 

	
	public static void main(String[] args) {

		String target1Path = "D:\\soft\\Java\\jdk_1.8.0.0_64";
		String target2Path = "D:\\soft\\Java\\jdk1.7.0_72";
		compareFileDorector( target1Path, target2Path); 
		compareFileDorector( target2Path, target1Path);
	}
	
	

	/**
	 *
	 * 左边 多的 + 
	 * 左边少的  -
	 *
	 */
	private static void compareFileDorector( String target1Path,String target2Path) {
         if(  new File(target1Path).isDirectory()){
			 String[] target1PathList = new File(target1Path).list();
			 String[] target2PathList = new File(target2Path).list();
			 for (int i = 0; i < target1PathList.length; i++) {
				 String target1FileName = target1PathList[i];
				 boolean  target1FileExits= Arrays.asList(target2PathList).contains(target1FileName); 
				 boolean target1FileIsDirectory = new File(target1Path,target1FileName).isDirectory();
				 if ( target1FileExits ) {
					 boolean target2FileIsDirectory = new File(target2Path,target1FileName).isDirectory();
					 boolean isSameDirectory = target1FileIsDirectory ^ target2FileIsDirectory;
					 if (isSameDirectory) { //文件存在,并且 文件类型不同
						 printInfo(target1Path,target2Path,target1FileName,target1FileExits,target1FileIsDirectory,target2FileIsDirectory);
					 }else{
						//文件存在,并且 文件类型相同 
					    compareFileDorector( new File(target1Path,target1FileName).getAbsolutePath(), new File(target2Path,target1FileName).getAbsolutePath());
					 }
				 }else { //文件夹不存在,并且 文件一 是 文件夹
					 printInfo(target1Path,target2Path,target1FileName,target1FileExits,target1FileIsDirectory,false);
					 
				 }
			}
       }
      
         
	} 

	//1.0文件存在并且文件类型不同,才会打印,
	 //1.1 文件不存在,类型是文件夹,循环打印
	 //1.2 文件不存在,类型是文件,打印一次
	private static void printInfo(String target1Path, String target2Path,String target1FileName,
			boolean target1FileExits, boolean target1FileIsDirectory,
			boolean target2FileIsDirectory) {
		if (target1FileExits) {
			File file1 = new File(target1Path,target1FileName);
			File file2 = new File(target2Path,target1FileName);
			String absolutePath1 = file1.getAbsolutePath();
			String absolutePath2 = file2.getAbsolutePath();
			 System.out.println(absolutePath1 +"\t" +target1FileIsDirectory +"\t"+absolutePath2+"\t"+target2FileIsDirectory);
			 return;
		}else if(target1FileIsDirectory){
			File file1 = new File(target1Path,target1FileName);
			if(file1.isDirectory()){
				String[]  target1PathList= file1.list();
				for (int i = 0; i < target1PathList.length; i++) {
					 String target1FileName1 = target1PathList[i];
					 String target1Path1 = new File(target1Path,target1FileName1).getAbsolutePath();
					 boolean target1FileIsDirectory1 = new File(target1Path,target1FileName1).isDirectory();
					 printInfo(target1Path,"",target1FileName1,false,target1FileIsDirectory1,false);
				}
			}else{
				return;
			}
		}else{
			File file1 = new File(target1Path,target1FileName);
			String absolutePath1 = file1.getAbsolutePath();
			System.out.println(absolutePath1 +"\t" +target1FileIsDirectory +"\t  \t ");
			return;
		}
	}
	
	

}

 

 

 

 

 

 

 

 

 

 

 

 

 

捐助开发者 

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。

 

个人主页http://knight-black-bob.iteye.com/



 
 
 谢谢您的赞助,我会做的更好!

目录
相关文章
|
Ubuntu Java Linux
|
Java
JDK1.8源码下载及获取、导入IDEA阅读、配置JDK源码
本文是博主学习JDK源码的记录,希望对大家有所帮助。
1941 0
JDK1.8源码下载及获取、导入IDEA阅读、配置JDK源码
|
3月前
|
前端开发 Java
2022最新版JDK1.8的安装教程、包含jdk1.8的提取码(亲测可用)
这篇文章提供了详细的JDK 1.8的安装步骤,包括下载、安装向导、环境变量配置,以及如何检查安装是否成功的方法。
2022最新版JDK1.8的安装教程、包含jdk1.8的提取码(亲测可用)
|
5月前
|
Ubuntu Java Linux
Ubuntu20.04下载jdk遇到各种奇怪问题大集,Linux如何将默认的OpenJDK切换成自己安装的JDK版本(以JDK1.8为例),无需卸载原有OpenJDK,Some packages co
Ubuntu20.04下载jdk遇到各种奇怪问题大集,Linux如何将默认的OpenJDK切换成自己安装的JDK版本(以JDK1.8为例),无需卸载原有OpenJDK,Some packages co
|
Java CDN
Mac 下安装jdk1.7和jdk1.8并实现任意版本自动切换
Mac 下安装jdk1.7和jdk1.8并实现任意版本自动切换
706 0
|
存储 安全 算法
HashMap为什么在多线程操作下不安全(jdk1.7和jdk1.8原因不同)
HashMap为什么在多线程操作下不安全(jdk1.7和jdk1.8原因不同)
96 0
|
安全 Java
【JDK】jdk1.8下载与安装教程
【JDK】jdk1.8下载与安装教程
1533 0
尝试用jdk1.6强行装jdk1.8的逼-Filter
尝试用jdk1.6强行装jdk1.8的逼-Filter
|
Oracle Java 关系型数据库
eclipse 环境 JDK1.8 换成 JDk1.7【以及此错误only available on Java 1.5 and highe 】
eclipse 环境 JDK1.8 换成 JDk1.7【以及此错误only available on Java 1.5 and highe 】
160 0
eclipse 环境 JDK1.8 换成 JDk1.7【以及此错误only available on Java 1.5 and highe 】
|
存储 算法 Java
JDK1.7与JDK1.8中HashMap的扩容
JDK1.7与JDK1.8中HashMap的扩容
JDK1.7与JDK1.8中HashMap的扩容