src/main/java/com/lf/server/config/InitConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/helper/FileHelper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/lf/server/config/InitConfig.java
@@ -234,16 +234,20 @@ String file = "E:\\data\\mpt\\A4mpt20131125.mpt"; long stime = System.currentTimeMillis(); //String md51 = FileHelper.getFileMd5(file); String md51 = FileHelper.getFileMd5(new java.io.File(file)); String md51 = FileHelper.getFileMd5(file); long etime = System.currentTimeMillis(); String s1 = String.format("执行时长:%d 毫秒.", (etime - stime)); stime = System.currentTimeMillis(); String md52 = FileHelper.getFastMd5(file); String md52 = FileHelper.getMd5ByJdk(file); etime = System.currentTimeMillis(); String s2 = String.format("执行时长:%d 毫秒.", (etime - stime)); stime = System.currentTimeMillis(); String md53 = FileHelper.getFastMd5(file); etime = System.currentTimeMillis(); String s3 = String.format("执行时长:%d 毫秒.", (etime - stime)); etime = System.currentTimeMillis(); } catch (Exception ex) { // src/main/java/com/lf/server/helper/FileHelper.java
@@ -197,9 +197,9 @@ } /** * 获取文件 MD5 码 * 获取文件MD5码(JDK) */ public static String getFileMd5(String filePath) throws IOException { public static String getMd5ByJdk(String filePath) throws IOException { FileInputStream fileStream = new FileInputStream(filePath); String md5 = DigestUtils.md5Hex(fileStream); fileStream.close(); @@ -305,16 +305,16 @@ /** * 获取文件的MD5 * @param file * @param filePath * @return */ @SuppressWarnings("unused") public static String getFileMd5(File file) { public static String getFileMd5(String filePath) { FileInputStream fis = null; try { MessageDigest md = MessageDigest.getInstance("MD5"); fis = new FileInputStream(file); fis = new FileInputStream(new File(filePath)); FileChannel fChannel = fis.getChannel(); ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 1024);