Class Splitter

java.lang.Object
cloud.opencode.base.string.builder.Splitter

public final class Splitter extends Object
String Splitter - Fluent string splitting with configurable options. 字符串分割器 - 提供可配置选项的流式字符串分割。

Features | 主要功能:

  • Split by string, char, pattern, or CharMatcher - 按字符串、字符、正则或CharMatcher分割
  • Fixed-length splitting - 固定长度分割
  • Trim and omit empty strings - 去空格和忽略空串
  • Map splitting with key-value separators - 键值对分割

Usage Examples | 使用示例:

// Basic split
List<String> parts = Splitter.on(",").splitToList("a,b,c"); // ["a","b","c"]

// Trim and omit empty
List<String> clean = Splitter.on(",").trimResults().omitEmptyStrings()
    .splitToList("a, ,b,,c"); // ["a","b","c"]

// Map split
Map<String, String> map = Splitter.on("&").withKeyValueSeparator("=")
    .split("key=value&foo=bar"); // {key=value, foo=bar}

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Null-safe: No (input must not be null) - 空值安全: 否(输入不能为空)
Since:
JDK 25, opencode-base-string V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: