比较文件内容是否一样,比较文件内容,比较文件内容是否一致,前
分享于 点击 32794 次 点评:247
比较文件内容是否一样,比较文件内容,比较文件内容是否一致,前
比较文件内容是否一致,前段时间写过一个MD5比较的,太强大了。连创建时间都比较了。。今天遇到一个需求不满足就,就写了此类。
/** * @方法功能说明:比较比较文件内容是否一致,根据字节比较 * @参数:@param f1 * @参数:@param f2 * @参数:@return * @参数:@throws IOException * @return:boolean */public boolean compareFileContentByChar(File f1 ,File f2) throws IOException{ FileInputStream fis1 = new FileInputStream(f1); FileInputStream fis2 = new FileInputStream(f2); int b = 0; int c = 0; while(true){ b = fis1.read(); c = fis2.read(); if(b!=-1 && c!=-1){ if(b!=c){ return false; } }else{ break; } } return true;}//该片段来自于http://byrx.net
用户点评