From 24569b81c8a5d8ae398117b73da21aab2b406795 Mon Sep 17 00:00:00 2001 From: looly Date: Wed, 5 Jan 2022 18:28:45 +0800 Subject: [PATCH] fix bug --- .../main/java/cn/hutool/core/text/CharSequenceUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/text/CharSequenceUtil.java b/hutool-core/src/main/java/cn/hutool/core/text/CharSequenceUtil.java index 38f56fbd3..bfefd2779 100644 --- a/hutool-core/src/main/java/cn/hutool/core/text/CharSequenceUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/text/CharSequenceUtil.java @@ -4239,12 +4239,12 @@ public class CharSequenceUtil { return str.charAt(0) + ".." + str.charAt(strLength - 1); } - final int w2 = (maxLength - 3) / 2; - final int w1 = w2 + (maxLength - 3) % 2; // w2 或 w2 + 1 + final int suffixLength = (maxLength - 3) / 2; + final int preLength = suffixLength + (maxLength - 3) % 2; // suffixLength 或 suffixLength + 1 final String str2 = str.toString(); return format("{}...{}", - str2.substring(0, w1), - str2.substring(strLength - w2)); + str2.substring(0, preLength), + str2.substring(strLength - suffixLength)); } /**