【JAVA】生成一个32位的随机数。防止重复,保留唯一性

作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985
QQ986945193 微博:http://weibo.com/mcxiaobing

import java.util.UUID;

/**
 * 
 * @author :程序员小冰
 * 
 * @新浪微博 :http://weibo.com/mcxiaobing
 * 
 * @version V1.0正式版 ctrl+y变小写
 * 
 * @process 由于是随机数,所以,下面的打印结果只是此次的结果
 * 
 * @Note http://blog.csdn.net/qq_21376985
 * 
 * @dateTime 2016-3-14下午10:47:31
 * 
 */
public class GetGuidRandom {
    public static void main(String[] args) {
        UUID uuid = UUID.randomUUID();
        /**
         * .{6c0222ed-e7f5-4cad-a717-a9abfb372239}
         */
        System.out.println(".{" + uuid.toString() + "}");
        /**
         * 6c0222ed-e7f5-4cad-a717-a9abfb372239
         */
        System.out.println(uuid.toString());
        /**
         * 36
         */
        System.out.println(uuid.toString().length());
        /**
         * 32
         */
        System.out.println(uuid.toString().replace("-", "").length());
        /**
         * 6c0222ede7f54cada717a9abfb372239
         */
        System.out.println(uuid.toString().replace("-", ""));
    }

}
原文地址:https://www.cnblogs.com/mcxiaobing/p/5907340.html