1
0
mirror of https://gitee.com/dromara/hutool.git synced 2025-04-05 17:37:59 +08:00
This commit is contained in:
Looly 2022-01-17 19:16:07 +08:00
parent 727e561c1a
commit db5bd528ce
5 changed files with 32 additions and 14 deletions
CHANGELOG.md
hutool-core/src
main/java/cn/hutool/core
test/java/cn/hutool/core/text/split

View File

@ -25,6 +25,7 @@
* 【core 】 修复java.time.Month解析问题issue#2090@Github
* 【core 】 修复PathUtil.moveContent移动覆盖导致的问题issue#I4QV0L@Gitee
* 【core 】 修复Opt.ofTry中并发环境下线程安全问题pr#504@Gitee
* 【core 】 修复PatternFinder中end边界判断问题issue#2099@Github
-------------------------------------------------------------------------------------------------------------
# 5.7.19 (2022-01-07)

View File

@ -571,16 +571,6 @@ public class NetUtil {
return null;
}
/**
* 获得本机物理地址
*
* @return 本机物理地址
* @since 5.7.3
*/
public static byte[] getLocalHardwareAddress() {
return getHardwareAddress(getLocalhost());
}
/**
* 获得指定地址信息中的硬件地址
*
@ -604,6 +594,16 @@ public class NetUtil {
return null;
}
/**
* 获得本机物理地址
*
* @return 本机物理地址
* @since 5.7.3
*/
public static byte[] getLocalHardwareAddress() {
return getHardwareAddress(getLocalhost());
}
/**
* 获取主机名称一次获取会缓存名称
*

View File

@ -66,7 +66,7 @@ public class PatternFinder extends TextFinder {
}else{
limit = Math.min(endIndex, text.length());
}
return end < limit ? end : INDEX_NOT_FOUND;
return end <= limit ? end : INDEX_NOT_FOUND;
}
@Override

View File

@ -87,9 +87,8 @@ public class SplitIter extends ComputeIter<String> implements Serializable {
}
// 找到新的分隔符位置
final int end = finder.end(start);
final String result = text.substring(offset, start);
offset = end;
offset = finder.end(start);
if (ignoreEmpty && result.isEmpty()) {
// 发现空串且需要忽略时跳过之

View File

@ -11,7 +11,7 @@ import java.util.List;
* @author Looly
*
*/
public class StrSpliterTest {
public class StrSplitterTest {
@Test
public void splitByCharTest(){
@ -71,4 +71,22 @@ public class StrSpliterTest {
Assert.assertNotNull(strings);
Assert.assertEquals(0, strings.length);
}
/**
* https://github.com/dromara/hutool/issues/2099
*/
@Test
public void splitByRegexTest(){
String text = "01 821 34567890182345617821";
List<String> strings = StrSplitter.splitByRegex(text, "21", 0, false, true);
Assert.assertEquals(2, strings.size());
Assert.assertEquals("01 8", strings.get(0));
Assert.assertEquals(" 345678901823456178", strings.get(1));
strings = StrSplitter.splitByRegex(text, "21", 0, false, false);
Assert.assertEquals(3, strings.size());
Assert.assertEquals("01 8", strings.get(0));
Assert.assertEquals(" 345678901823456178", strings.get(1));
Assert.assertEquals("", strings.get(2));
}
}