package com.founder.PGIS_TL_Privilege.util;

    import org.springframework.util.DigestUtils;

    import java.io.IOException;
    import java.security.GeneralSecurityException;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.text.DecimalFormat;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.UUID;
    import java.util.stream.Collectors;

    /*
    @ClassName UuidUtil
    *
    @Description UUID生成
    *
    @Author lixiaohu
    *
    @Date 2018/5/10
    **/
    _public class UuidUtil {
    public static String createUUID() {
    //获取UUID并转化为String对象
    String uuid = UUID._randomUUID
    ().toString();
    //因为UUID本身为32位只是生成时多了“-”,所以将它们去点就可
    uuid = uuid.replace(“-“, “”);
    return uuid;
    }

    1. public static String sizeCoverter(Double size) {<br /> //定义GB的计算常量<br /> int GB = 1024 * 1024 * 1024;<br /> //定义MB的计算常量<br /> int MB = 1024 * 1024;<br /> //定义KB的计算常量<br /> int KB = 1024;<br /> DecimalFormat df = new DecimalFormat("0.00");//格式化小数<br /> String resultSize = "";<br /> if (size / GB / 1024 >= 1) {<br /> resultSize = df.format(size / (float) GB / 1024) + "TB";<br /> } else if (size / GB >= 1) {<br /> //如果当前Byte的值大于等于1GB<br /> resultSize = df.format(size / (float) GB) + "GB";<br /> } else if (size / MB >= 1) {<br /> //如果当前Byte的值大于等于1MB<br /> resultSize = df.format(size / (float) MB) + "MB";<br /> } else if (size / KB >= 1) {<br /> //如果当前Byte的值大于等于1KB<br /> resultSize = df.format(size / (float) KB) + "KB";<br /> } else {<br /> resultSize = size + "B";<br /> }<br /> return resultSize;<br /> }
    2. _/**<br /> * MD5<br /> *<br /> * _**_@param _**_basestring basestring<br /> * _**_@return _**_value<br /> * _**_@throws _**_IOException IO异常<br /> */<br /> _public final static String md5(String basestring) throws IOException {<br /> byte[] bytes = null;<br /> try {<br /> MessageDigest md5 = MessageDigest._getInstance_("MD5");<br /> bytes = md5.digest(basestring.getBytes("UTF-8"));<br /> } catch (GeneralSecurityException ex) {<br /> throw new IOException(ex);<br /> }
    3. // 将MD5输出的二进制结果转换为小写的十六进制<br /> StringBuilder sign = new StringBuilder();<br /> for (int i = 0; i < bytes.length; i++) {<br /> String hex = Integer._toHexString_(bytes[i] & 0xFF);<br /> if (hex.length() == 1) {<br /> sign.append("0");<br /> }<br /> sign.append(hex);<br /> }<br /> return sign.toString();<br /> }
    4. public static void main(String[] args) {<br />// System.out.println(sizeCoverter(1671324303236d));<br /> try {<br /> System._out_.println(_md5_("223456"));<br /> } catch (IOException e) {<br /> e.printStackTrace();<br /> }
    5. }

    }