- /**
- * 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代码收藏
最新推荐文章于 2023-02-22 16:40:31 发布
本文介绍了一种使用CRC校验进行jar文件完整性的Java实现方法,并列举了可能出现的一些异常情况及其处理方式。
4279

被折叠的 条评论
为什么被折叠?



