Class CsvUtil

java.lang.Object
cloud.opencode.base.string.parse.CsvUtil

public final class CsvUtil extends Object
CSV Utility - Provides CSV parsing and formatting methods. CSV工具 - 提供CSV解析和格式化方法。

Features | 主要功能:

  • CSV content parsing to rows/columns - CSV内容解析为行列
  • Header-based parsing to Map list - 基于表头解析为Map列表
  • CSV generation from row data - 从行数据生成CSV

Usage Examples | 使用示例:

List<List<String>> rows = CsvUtil.parse("name,age\nAlice,30\nBob,25");
List<Map<String, String>> data = CsvUtil.parseWithHeader("name,age\nAlice,30");
String csv = CsvUtil.toCsv(List.of(List.of("a", "b"), List.of("1", "2")));

Security | 安全性:

  • Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具类)
  • Null-safe: Yes - 空值安全: 是

Performance | 性能特性:

  • Time complexity: O(n) where n = input length - O(n), n为输入长度
  • Space complexity: O(n) for parsed output - 解析输出 O(n)
Since:
JDK 25, opencode-base-string V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: