tangtang2009的gravatar头像
tangtang2009 2013-12-09 15:35:45

java去掉UUID的小横线的算法

几行代码,很简单,直接贴了,处女分享:

	public static String genUUID(){
		UUID uuid  =  UUID.randomUUID(); 
		String s = uuid.toString();//
		int p = 0;
		int j = 0;
		char[] buf = new char[32];
		while(p<s.length()){
		 char c = s.charAt(p);
		 p+=1;
		 if(c=='-')continue;
		 buf[j]=c;j+=1;
		}
		return new String(buf);
	}

刚才没弄好,重新发一下,惭愧惭愧。。。。。

 

我来提供一份简单的:

 UUID uuid  =  UUID.randomUUID();

System.out.println(uuid);
System.out.println(uuid.toString().replaceAll("\\-", ""));


最代码官方编辑于2013-12-9 15:57:03


打赏

最代码最近下载分享源代码列表最近下载
最代码最近浏览分享源代码列表最近浏览
浪里格朗  LV4 2023年1月31日
refsdf 2022年2月23日
暂无贡献等级
tanhuizhao  LV1 2021年12月9日
帅得惊动党中央  LV2 2021年11月25日
jachyn  LV6 2021年6月12日
xiaocai83 2021年5月15日
暂无贡献等级
SpringClouddddd  LV1 2021年4月7日
zyvslxl  LV1 2021年1月11日
lyf735404822  LV1 2020年12月24日
flentoe  LV2 2020年7月31日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友