From 2727004b7a4ed275c5f0e473a1f8feba4ac8149a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E5=85=83?= <11529698+wooden-yuan@user.noreply.gitee.com> Date: Mon, 22 Jan 2024 03:53:54 +0000 Subject: [PATCH] =?UTF-8?q?add=20=E5=AE=9E=E7=94=A8=E5=B0=8F=E5=B7=A5?= =?UTF-8?q?=E5=85=B7/StrUtils.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 木元 <11529698+wooden-yuan@user.noreply.gitee.com> --- .../StrUtils" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "\345\256\236\347\224\250\345\260\217\345\267\245\345\205\267/StrUtils" diff --git "a/\345\256\236\347\224\250\345\260\217\345\267\245\345\205\267/StrUtils" "b/\345\256\236\347\224\250\345\260\217\345\267\245\345\205\267/StrUtils" new file mode 100644 index 0000000..0aa9303 --- /dev/null +++ "b/\345\256\236\347\224\250\345\260\217\345\267\245\345\205\267/StrUtils" @@ -0,0 +1,51 @@ + + +public class StrUtils { + + /** + * 高性能的Split,针对char的分隔符号,比JDK String自带的高效. + *
+ * copy from Commons Lange 3.5 StringUtils, 做如下优化: + *
+ * 1. 最后不做数组转换,直接返回List. + *
+ * 2. 可设定List初始大小. + *
+ * 3. preserveAllTokens 取默认值false
+ *
+ * @param expectParts 预估分割后的List大小,初始化数据更精准
+ * @return 如果为null返回null, 如果为""返回空数组
+ */
+ public static List