Code
/**
* jar完整性测试/检测的Java代码(CRC检测)<br>
* 一些常见的异常,也就是类似CRC异常 <br>
* Unexpected end of ZLIB input stream<br>
* oversubscribed dynamic bit lengths tree
*
* @param fileName
* @return
*/
public static boolean checkJarFile(File fileName) {
try {
JarFile jf = new JarFile(fileName);
for (Enumeration e = jf.entries(); e.hasMoreElements();) {
JarEntry je = (JarEntry) e.nextElement();
String outFileName = je.getName();
if (outFileName.endsWith("/") || outFileName.endsWith("\\") || outFileName.endsWith(File.separator)) {} else {
InputStream in = jf.getInputStream(je);
byte[] buffer = new byte[2048];
while (in.read(buffer) > 0) {
;
}
in.close();
}
}
return true;
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
}
jar完整性测试的Java代码
posted on
2009-02-17 08:25
老紫竹
阅读(
364)
评论()
编辑
收藏
举报