mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix indexOf bug
This commit is contained in:
parent
3fee3f2a9c
commit
84494f4ef2
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.4.1 (2020-08-24)
|
||||
# 5.4.1 (2020-08-27)
|
||||
|
||||
### 新特性
|
||||
* 【core 】 StrUtil增加firstNonXXX方法(issue#1020@Github)
|
||||
@ -18,10 +18,12 @@
|
||||
* 【core 】 增加CalendarUtil和DateUtil增加isSameMonth方法(pr#161@Gitee)
|
||||
* 【core 】 Dict增加of方法(issue#1035@Github)
|
||||
* 【core 】 StrUtil.wrapAll方法不明确修改改为wrapAllWithPair(issue#1042@Github)
|
||||
* 【core 】 EnumUtil.getEnumAt负数返回null(pr#167@Gitee)
|
||||
|
||||
### Bug修复#
|
||||
* 【poi 】 修复ExcelBase.isXlsx方法判断问题(issue#I1S502@Gitee)
|
||||
* 【poi 】 修复Excel03SaxReader日期方法判断问题(pr#1026@Github)
|
||||
* 【core 】 修复StrUtil.indexOf空指针问题(issue#1038@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -3427,7 +3427,7 @@ public class StrUtil {
|
||||
* @param start 起始位置,如果小于0,从0开始查找
|
||||
* @return 位置
|
||||
*/
|
||||
public static int indexOf(final CharSequence str, char searchChar, int start) {
|
||||
public static int indexOf(CharSequence str, char searchChar, int start) {
|
||||
if (str instanceof String) {
|
||||
return ((String) str).indexOf(searchChar, start);
|
||||
} else {
|
||||
@ -3445,6 +3445,9 @@ public class StrUtil {
|
||||
* @return 位置
|
||||
*/
|
||||
public static int indexOf(final CharSequence str, char searchChar, int start, int end) {
|
||||
if(isEmpty(str)){
|
||||
return INDEX_NOT_FOUND;
|
||||
}
|
||||
final int len = str.length();
|
||||
if (start < 0 || start > len) {
|
||||
start = 0;
|
||||
@ -3457,7 +3460,7 @@ public class StrUtil {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return INDEX_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user