生成url格式base64编码的uuid
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.UUID;
public class Base64UUIDHelper {
public Base64UUIDHelper() {
}
public static String getBase64Uuid() {
UUID temp = UUID.randomUUID();
byte[] bytes = new byte[16];
long half = temp.getLeastSignificantBits();
int i;
for(i = 0; i < 8; ++i) {
bytes[i] = (byte)((int)(half & 255L));
half >>= 8;
}
half = temp.getMostSignificantBits();
for(i = 8; i < 16; ++i) {
bytes[i] = (byte)((int)(half & 255L));
half >>= 8;
}
return (new String(Base64.getUrlEncoder().encode(bytes), StandardCharsets.UTF_8)).substring(0, 22);
}
}