Class OpenTruncate
java.lang.Object
cloud.opencode.base.string.text.OpenTruncate
String Truncate Utility - Provides string truncation methods.
字符串截断工具 - 提供字符串截断方法。
Features | 主要功能:
- Head truncation with ellipsis - 头部截断带省略号
- Middle truncation - 中间截断
- Byte-based truncation for multi-byte strings - 基于字节的截断
Usage Examples | 使用示例:
String t = OpenTruncate.truncate("Hello World", 8); // "Hello..."
String m = OpenTruncate.truncateMiddle("abcdefghij", 7); // "ab...ij"
Security | 安全性:
- Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具类)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic Stringstatic StringtruncateByBytes(String str, int maxBytes, String charset) static StringtruncateMiddle(String str, int maxLength) static StringtruncateMiddle(String str, int maxLength, String ellipsis)
-
Method Details
-
truncate
-
truncate
-
truncateMiddle
-
truncateMiddle
-
truncateByBytes
-