jar完整性测试的Java代码收藏
2018年02月02日
⁄ 综合
⁄ 共 855字 ⁄ 字号
小 中 大
-
-
-
-
-
-
-
-
-
- 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;
- }
- }