I need to implement data exporter to CSV using java. It must meet next requirements:
1) it must be configurable (e.g. an order or number of columns must not be hard coded)
2) this data can be in different languages (also Chinese) and the resulting csv files must be utf-8 encoded.
I've never worked with such kind of tasks, so I just want to ask if somebody could provide me some useful advises: what are the best practices in configuring a data exporter and encoding data.
I've already found the following discussion about different csv exporter/importer CSV API for Java but if you have something to add, don't hesitate to do this ;)
And I've also heard something about drools, but have no clue yet could it be the solution in my case?
Thanks a lot for your replies!
CSV is a really simple format. Here's basically the gist of encoding/decoding.
Encoding:
/
with//
and all"
with/"
, wrap it in quotes, and emit it.Decoding:
//
with/
and/"
with"
until you reach a quote that wasn't preceded by a single backslash.You should not need to be worried about encoding; Java should handle that fine. But really, unless this is specifically for a school asignment, or something like that, you should be using a pre-existing CSV library.