mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
!76 [新特性] 获得一个随机的字符串(只包含数字和字符) 并排除指定字符串
Merge pull request !76 from Kui_Ye/v4-dev
This commit is contained in:
commit
17efa74406
@ -391,6 +391,22 @@ public class RandomUtil {
|
|||||||
return randomString(BASE_CHAR_NUMBER, length).toUpperCase();
|
return randomString(BASE_CHAR_NUMBER, length).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得一个随机的字符串(只包含数字和字符) 并排除指定字符串
|
||||||
|
*
|
||||||
|
* @param length 字符串的长度
|
||||||
|
* @param elemData 要排除的字符串
|
||||||
|
* @return 随机字符串
|
||||||
|
*/
|
||||||
|
public static String randomStringWithoutStr(int length,String elemData) {
|
||||||
|
String baseStr=BASE_CHAR_NUMBER;
|
||||||
|
baseStr=StrUtil.removeAll(baseStr,elemData.toCharArray());
|
||||||
|
if(baseStr.equals("")){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return randomString(baseStr, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得一个只包含数字的字符串
|
* 获得一个只包含数字的字符串
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user