管道基础大数据平台系统开发-【后端】-Server
1.5
13693261870
2023-01-05 e5f61db766b3eaa28506835e3581cbd2fdc8533d
src/main/java/com/lf/server/helper/FileHelper.java
@@ -1,7 +1,7 @@
package com.lf.server.helper;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.data.MetaEntity;
import com.twmacinta.util.MD5;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.logging.Log;
@@ -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();
@@ -222,9 +222,9 @@
    /**
     * 删除文件
     */
    public static void deleteFiles(List<MetaFileEntity> list) {
    public static void deleteFiles(List<MetaEntity> list) {
        try {
            for (MetaFileEntity mf : list) {
            for (MetaEntity mf : list) {
                File f = new File(mf.getPath());
                if (f.exists()) {
                    f.delete();
@@ -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);