管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-01-08 427bee04bfacf44abe5d595e2dad976747d83dba
src/main/java/com/lf/server/helper/FileHelper.java
@@ -1,6 +1,7 @@
package com.lf.server.helper;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.twmacinta.util.MD5;
import org.apache.commons.codec.digest.DigestUtils;
@@ -197,9 +198,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 +306,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);