Parsing a csv file in Java [duplicate]
Possible Duplicate:
Parsing CSV in java
How to do I parse a csv file correctly in java? There are cases where simple StringTokenizer doesn't work as in the example below:
xxx,"hello, this breaks you"
Try using a dedicated library for that, e.g.:
- http://opencsv.sourceforge.net/
JSaPar is another library that will do the work for you. You can find a comprehensive list of other alternative libraries here.
ostermiller.org has a jar with nice utility-classes like CSV-Parser/Writer etc.
Java Data File Read/Write Utility is a very straight forward and easy to use library for reading/writing CSV files.
- Most important class's documentation - DataFile
- Download
BeanIO can be used to bind CSV records to Java bean objects. Visit http://beanio.org for details.
精彩评论