标签:replace color class main system 格式 字符串 pack buffer
package cc.ccoder.mail.utils; import java.util.UUID; /** * * @TODO: 生成随机字符串的工具类 uuid */ public class UUIDUtils { public static String getUUID(){ return UUID.randomUUID().toString().replace("-", ""); } public static void main(String[] args) { System.out.println("格式前的UUID : " + UUID.randomUUID().toString()); System.out.println("格式化后的UUID :" + getUUID()); } }
对同一UUID进行操作:
//获取uuid public static synchronized String getUUID() { String[] arg = UUID.randomUUID().toString().split("-"); StringBuffer stringBuffer = new StringBuffer(); for (String str : arg) { stringBuffer.append(str); } return stringBuffer.toString(); }
标签:replace color class main system 格式 字符串 pack buffer
原文地址:https://www.cnblogs.com/zhuo-zui/p/13171325.html