生成文件的MD5哈希码

package com.wdzl1;

import org.springframework.util.DigestUtils;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class Test {
    public static void main(String[] args) throws Exception {
        String filename = "C:\\Users\\Administrator\\Desktop\\police.sql";
        InputStream fis =  new FileInputStream(filename);
        BufferedInputStream bis = new BufferedInputStream(fis);
        System.out.println(DigestUtils.md5DigestAsHex(bis));
        bis.close();
        fis.close();
        String filename1 = "E:\\police.sql";
        InputStream fis1 =  new FileInputStream(filename1);
        BufferedInputStream bis1 = new BufferedInputStream(fis1);
        System.out.println(DigestUtils.md5DigestAsHex(bis1));
        bis.close();
        fis.close();


    }
}

 

你可能感兴趣的:(生成文件的MD5哈希码)