mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
修复RandomUtil.randomStringWithoutStr方法问题
This commit is contained in:
parent
c108cbf001
commit
0b9b578f61
@ -17,6 +17,7 @@
|
||||
* 【extra 】 修复CompressUtil工具多出\问题(issue#I71K5V@Gitee)
|
||||
* 【db 】 解决oracle情况下setObject(inputStream)报错问题,java.sql.SQLException: 无效的列类型问题(pr#1207@Gitee)
|
||||
* 【core 】 解决CalendarUtil.isSameDay时区不同导致结果错误问题(pr#3548@Github)
|
||||
* 【core 】 修复RandomUtil.randomStringWithoutStr方法问题(pr#1209@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.27(2024-03-29)
|
||||
|
@ -8,22 +8,11 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.sun.imageio.plugins.common.ImageUtil;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.*;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
|
@ -599,15 +599,29 @@ public class RandomUtil {
|
||||
return randomString(BASE_CHAR_NUMBER, length).toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个随机的字符串(只包含数字和字母) 并排除指定字符串
|
||||
*
|
||||
* @param length 字符串的长度
|
||||
* @param elemData 要排除的字符串,如:去重容易混淆的字符串,oO0、lL1、q9Q、pP,区分大小写
|
||||
* @return 随机字符串
|
||||
*/
|
||||
public static String randomStringWithoutStr(final int length, final String elemData) {
|
||||
String baseStr = BASE_CHAR_NUMBER;
|
||||
baseStr = StrUtil.removeAll(baseStr, elemData.toCharArray());
|
||||
return randomString(baseStr, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得一个随机的字符串(只包含数字和小写字母) 并排除指定字符串
|
||||
*
|
||||
* @param length 字符串的长度
|
||||
* @param elemData 要排除的字符串,如:去重容易混淆的字符串,oO0、lL1、q9Q、pP,不区分大小写
|
||||
* @return 随机字符串
|
||||
* @since 5.8.28
|
||||
*/
|
||||
public static String randomStringWithoutStr(final int length, final String elemData) {
|
||||
String baseStr = BASE_CHAR_NUMBER;
|
||||
public static String randomStringLowerWithoutStr(final int length, final String elemData) {
|
||||
String baseStr = BASE_CHAR_NUMBER_LOWER;
|
||||
baseStr = StrUtil.removeAll(baseStr, elemData.toLowerCase().toCharArray());
|
||||
return randomString(baseStr, length);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user