Class CsvUtil
java.lang.Object
com.sure.tool.collection.CsvUtil
CSV 读写工具类(最小实现),支持引号包裹、引号内逗号与双引号转义,参考 Hutool 的
CsvUtil 设计。- Since:
- 0.1.0
- Author:
- suretool
-
Method Summary
Modifier and TypeMethodDescription读取 CSV 文件(UTF-8)。读取 CSV 文件(指定字符集)。read(InputStream in, Charset charset) 读取 CSV 输入流。解析 CSV 字符串。static String序列化为 CSV 字符串。static void写入 CSV 文件(UTF-8)。static void写入 CSV 文件(指定字符集)。static void写出 CSV 到 Writer。
-
Method Details
-
read
-
read
读取 CSV 文件(UTF-8)。- Parameters:
file- 文件- Returns:
- 行列表
- Throws:
IOException- 读取失败
-
toCsv
-
write
写入 CSV 文件(UTF-8)。- Parameters:
file- 文件rows- 行列表- Throws:
IOException- 写入失败
-
read
读取 CSV 文件(指定字符集)。- Parameters:
file- 文件charset- 字符集- Returns:
- 行数据
- Throws:
IOException- IO 异常
-
write
写入 CSV 文件(指定字符集)。- Parameters:
file- 文件rows- 行数据charset- 字符集- Throws:
IOException- IO 异常
-
read
读取 CSV 输入流。- Parameters:
in- 输入流charset- 字符集- Returns:
- 行列表
- Throws:
IOException- IO 异常
-
write
写出 CSV 到 Writer。- Parameters:
writer- Writerrows- 行列表- Throws:
IOException- IO 异常
-