fix indexOf bug

This commit is contained in:
Looly 2020-08-27 17:43:35 +08:00
parent 3fee3f2a9c
commit 84494f4ef2
2 changed files with 8 additions and 3 deletions

View File

@ -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方法不明确修改改为wrapAllWithPairissue#1042@Github
* 【core 】 EnumUtil.getEnumAt负数返回nullpr#167@Gitee
### Bug修复#
* 【poi 】 修复ExcelBase.isXlsx方法判断问题issue#I1S502@Gitee
* 【poi 】 修复Excel03SaxReader日期方法判断问题pr#1026@Github
* 【core 】 修复StrUtil.indexOf空指针问题issue#1038@Github
-------------------------------------------------------------------------------------------------------------

View File

@ -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;
}
/**