springboot获取文件的MD5

    public static String getMd5(String path) {
    
    
        String md5 = null;
        try (FileInputStream inputStream = new FileInputStream(ResourceUtils.getFile(path))) {
    
    
            md5 = DigestUtils.md5DigestAsHex(inputStream);
        } catch (Exception e) {
    
    
            log.error("get {} md5 error, {}", path, e.getMessage());
        }
        return md5;
    }

猜你喜欢

转载自blog.csdn.net/wzy_168/article/details/108152233