修复RandomUtil.randomStringWithoutStr方法问题

This commit is contained in:
Looly 2024-04-17 15:29:26 +08:00
parent c108cbf001
commit 0b9b578f61
3 changed files with 18 additions and 14 deletions

View File

@ -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)

View File

@ -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;

View File

@ -599,15 +599,29 @@ public class RandomUtil {
return randomString(BASE_CHAR_NUMBER, length).toUpperCase();
}
/**
* 获得一个随机的字符串只包含数字和字母 并排除指定字符串
*
* @param length 字符串的长度
* @param elemData 要排除的字符串,去重容易混淆的字符串oO0lL1q9QpP区分大小写
* @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 要排除的字符串,去重容易混淆的字符串oO0lL1q9QpP不区分大小写
* @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);
}