add mappingstrategy opencsv method
@@ -18,14 +18,17 @@ import java.util.List;
public class BeanExamples {
public static List<CsvBean> beanBuilderExample(Path path, Class clazz) {
+ ColumnPositionMappingStrategy ms = new ColumnPositionMappingStrategy();
+ return beanBuilderExample(path, clazz, ms);
+ }
+
+ public static List<CsvBean> beanBuilderExample(Path path, Class clazz, MappingStrategy ms) {
CsvTransfer csvTransfer = new CsvTransfer();
try {
- ColumnPositionMappingStrategy ms = new ColumnPositionMappingStrategy();
ms.setType(clazz);
Reader reader = Files.newBufferedReader(path);
- CsvToBean cb = new CsvToBeanBuilder(reader)
- .withType(clazz)
+ CsvToBean cb = new CsvToBeanBuilder(reader).withType(clazz)
.withMappingStrategy(ms)
.build();
@@ -42,8 +45,7 @@ public class BeanExamples {
try {
Writer writer = new FileWriter(path.toString());
- StatefulBeanToCsv sbc = new StatefulBeanToCsvBuilder(writer)
- .withSeparator(CSVWriter.DEFAULT_SEPARATOR)
+ StatefulBeanToCsv sbc = new StatefulBeanToCsvBuilder(writer).withSeparator(CSVWriter.DEFAULT_SEPARATOR)
.build();
List<CsvBean> list = new ArrayList<>();
