public static String generate8Code() {
2
StringBuffer shortBuffer = new StringBuffer();
3
String uuid = UUID.randomUUID().toString().replace("-", "");
4
for (int i = 0; i < 8; i++) {
5
String str = uuid.substring(i * 4, i * 4 + 4);
6
int x = Integer.parseInt(str, 16);
7
shortBuffer.append(chars[x % 0x3E]);
8
}
9
return shortBuffer.toString();
10
11
}
12
13
public static String[] chars = new String[] { "a", "b", "c", "d", "e", "f",
14
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
15
"t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
16
"6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
17
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
18
"W", "X", "Y", "Z" };