借助commons-lang3
将Java对象转为CSV格式的字符串。
调用ReflectionToStringBuilder
类的toString
方法实现
导入commons-lang3
依赖
<!-- commons lang-->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
code
DelimiterToStringStyle
实现ToStringStyle
类进行扩展。
package com.upupfeng.csv_parser;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @author mawf
* @see ToStringStyle
*/
public class DelimiterToStringStyle extends ToStringStyle {
private static final long serialVersionUID = 1L;
private static final String DEFAULT_DELI