package com.kerui.common.utils;
import java.util.Random;
import java.util.UUID;
public class StringUtil {
public static final String RANDOM_STR_$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";
public static final String RANDOM_STR = "abcdefghijklmnopqrstuvwxyz0123456789";
public static final String RANDOM_NUM = "0123456789";
public static String getRandomStringByNum(Integer n, String randomString){
if (null == n){
n = 4;
}
if (is_empty(randomString)){
randomString = RANDOM_STR_$;
}
StringBuffer sb = new StringBuffer();
char[] chars = randomString.toCharArray();
for (Integer i = 0; i < n; i++) {
char aChar = chars[new Random().nextInt(chars.length)];
sb.append(aChar);
}
return sb.toString();
}
public static boolean is_empty(String str){
return null == str || "".equals(str) || str.trim().length() == 0;
}
public static String getUUID(){
return UUID.randomUUID().toString().replaceAll("-", "");
}
}