| | |
| | | } |
| | | |
| | | /** |
| | | * 获取文件 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(); |
| | |
| | | |
| | | /** |
| | | * 获取文件的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); |
| | | |