zoukankan      html  css  js  c++  java
  • md5

    // 获取文件MD5值
        public static String getMd5(File file) throws FileNotFoundException {
            String value = null;
            FileInputStream in = null;
            try {
                in = new FileInputStream(file);
                MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
                MessageDigest md5 = MessageDigest.getInstance("MD5");
                md5.update(byteBuffer);
                BigInteger bi = new BigInteger(1, md5.digest());
                value = bi.toString(16);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (null != in) {
                    try {
                        in.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
            return value;
        }

  • 相关阅读:
    Java8基础之native方法
    Java基础之static关键字
    Java基础之继承
    Java之equals和hashCode方法
    Java基础之this关键字
    Java基础之super关键字
    Java基础之Serializable接口
    Java之反射学习
    Python3之多线程学习
    Python3之深拷贝和浅拷贝区别
  • 原文地址:https://www.cnblogs.com/wenwen123/p/5848051.html
Copyright © 2011-2022 走看看