1,生成UUID

package com.jeeplus.common.utils;

import java.util.UUID;

/**
* 生成唯一的UUID
*
* @author songyan
*
*/
public class UUIDUtils { /**
* 得到32位的uuid
*
* @return
*/
public static String getUUID32() {
return UUID.randomUUID().toString().replace("-", "").toLowerCase();
} /**
* 得到指定数量的UUID,以数组的形式返回
*
* @param num
* @return
*/
public static String[] getUUID(int num) {
if (num <= 0)
return null;
String[] uuidArr = new String[num];
for (int i = 0; i < uuidArr.length; i++) {
uuidArr[i] = getUUID32();
}
return uuidArr;
} public static String[] chars = new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
"V", "W", "X", "Y", "Z" }; /**
* 生成8位UUId
*
* @return
*/
public static String generateUuid8() {
StringBuffer shortBuffer = new StringBuffer();
String uuid = UUID.randomUUID().toString().replace("-", "");
for (int i = 0; i < 8; i++) {
String str = uuid.substring(i * 4, i * 4 + 4);
int x = Integer.parseInt(str, 16);
shortBuffer.append(chars[x % 0x3E]);
}
return shortBuffer.toString(); } }

生成随机位数的UUID的更多相关文章

  1. 生成随机字符串(UUID方法)

    这是另一种用UUID生成随机字符串的方法. public class RandomGenerator{ private int length; public void setLength(int le ...

  2. php生成随机产生六位数密码的代码

    php生成随机产生六位数密码的代码,供大家学习参考.本文转自:http://www.jbxue.com/article/6199.html php生成随机产生六位数密码的代码,供大家学习参考. 复制代 ...

  3. PHP随机生成要求位数个字符(大小写字母+数字)

    php随机生成要求位数个字符 /** * 随机生成要求位数个字符 * @param length 规定几位字符 */ function getRandChar($length){ $str = nul ...

  4. python随机生成6位数验证码

    #随机生成6位数验证码 import randomcode = []for i in range(6):    if i == str(random.randint(1,5)):        cod ...

  5. java生成随机六位数的验证码&随机生成十位数ValidCode码,用于邮件的验证&检查是不是符合为合法的中国的手机号码

    package com.demo.test1; import java.security.NoSuchAlgorithmException; import java.security.SecureRa ...

  6. python3 随机生成6位数的验证码

    python3 随机生成6位数的验证码 要求是数字:0~9 及大小写字母. #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung ...

  7. 生成随机uuid

      /**  * 生成随机uuid  */ export function uuid() {   return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.repla ...

  8. 生成随机id对比

    生成随机id 最近公司的项目游戏生成的随机不重复id,重复概率有点大, 代码如下: private static int id = 0; public static int serverID = 0; ...

  9. .net生成随机字符串

    生成随机字符串的工具类: /// <summary> /// 随机字符串工具类 /// </summary> public class RandomTools { /// &l ...

随机推荐

  1. webkit在vs2008中编译

    转载自:http://xjchilli.blog.163.com/blog/static/4534773920091016115533158/ webkit的官方网站写的webkit需要在vs2005 ...

  2. postfix导致maillog填满磁盘空间的巨坑!

    双休日回家pull在公司修改的代码...于是菜鸟的linux探索之路开始了 1.df -f发现磁盘又占满了(之前是node的error) 2.发现maillog整整10个G,无数条(Jul 7 04: ...

  3. WEB API 版本控制

    参照 http://blog.csdn.net/hengyunabc/article/details/20506345

  4. jQuery获取表格隐藏域与ajax请求数据结合显示详情

    0.表格样式

  5. ubuntu设置默认python版本

    原文:https://www.cnblogs.com/johnny1024/p/8400511.html ··· ubuntu 16.04本身是自带python的,他本身是自带2.X和3.X,两个版本 ...

  6. IOS开发代码分享之获取启动画面图片的string

    http://www.jb51.net/article/55309.htm 本代码支持 iPhone 6 以下. 支持 iPhone 及 iPad ? 1 2 3 4 5 6 7 8 9 10 11 ...

  7. 分享三个USB抓包软件---Bus Hound,USBlyzer 和-USBTrace【转】

    转自:http://bbs.armfly.com/read.php?tid=15377 Bus Hound官方下载地址:http://perisoft.net/bushound/ Bus Hound ...

  8. python基础===pip安装模块失败

    此情况只用于网络不畅的安装模块背景: 总出现红色的 Could not find a version that satisfies the requirement pymongo(from versi ...

  9. redis特性与使用场景

    一.8大特性 1.速度快 数据存储在内存,可达到10万OPS 2.可持久化,断电不丢数据 所有数据保存在内存中,对数据的更新异步的保存在硬盘中 3.多种数据结构 字符串.哈希.列表.集合.有序集 合位 ...

  10. 【转载】Linux中profile、bashrc、bash_profile之间的区别和联系

    如果你想对所有的使用bash的用户修改某个配置并在以后打开的bash都生效的话可以修改这个文件,修改这个文件不用重启,重新打开一个bash即可生效.~/.bash_profile:每个用户都可使用该文 ...