- Type Parameters:
T- the type of object to write
from(Class) to create one.
The DSL allows to create a CsvWriter easily. The CsvWriter will by default append the headers on the call to CsvWriter.CsvWriterDSL.to(Appendable)
Because the DSL create a mapper it is better to cache the CsvWriter.CsvWriterDSL.
CsvWriter csvWriter = CsvWriter.from(MyObject.class).to(myWriter);
csvWriter.append(obj1).append(obj2);
You can deactivate that by calling CsvWriter.CsvWriterDSL.skipHeaders()
CsvWriter csvWriter = CsvWriter.from(MyObject.class).skipHeaders().to(myWriter);
You can also specified the property names.
CsvWriter csvWriter = CsvWriter.from(MyObject.class).columns("id", "name").to(myWriter);
Or add a property with a specified format
CsvWriter csvWriter = CsvWriter.from(MyObject.class).columns("date", new SimpleDateFormat("yyyyMMdd")).to(myWriter);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classthe csv writer DSLstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionwrite the specified value to the underlying appendable.static <T> CsvWriter.CsvWriterDSL<T>Create a DSL on the specified type.static <T> CsvWriter.CsvWriterDSL<T>Create a DSL on the specified type.static <T> CsvWriter.CsvWriterDSL<T>from(org.simpleflatmapper.util.TypeReference<T> typeReference) Create a DSL on the specified type.
-
Method Details
-
append
write the specified value to the underlying appendable.- Parameters:
value- the value to write- Returns:
- the current writer
- Throws:
IOException- If an I/O error occurs
-
from
Create a DSL on the specified type.- Type Parameters:
T- the type- Parameters:
type- the type of object to write- Returns:
- a DSL on the specified type
-
from
public static <T> CsvWriter.CsvWriterDSL<T> from(org.simpleflatmapper.util.TypeReference<T> typeReference) Create a DSL on the specified type.- Type Parameters:
T- the type- Parameters:
typeReference- the type of object to write- Returns:
- a DSL on the specified type
-
from
Create a DSL on the specified type.- Type Parameters:
T- the type- Parameters:
type- the type of object to write- Returns:
- a DSL on the specified type
-