-bottom

net.sf.csv4j
Class CSVParser

java.lang.Object
  extended by net.sf.csv4j.CSVParser

public class CSVParser
extends Object

Parses CSV lines of text. Options are available to choose the

Notes: Line with trailing comma will result in an empty string field

Attempts to follow this suggestion from RFC4180: Implementors should "be conservative in what you do, be liberal in what you accept from others" (RFC 793) when processing CSV files.

Since:
1.0
Author:
Shawn Boyce
See Also:
Comma Separated Values on Wikipedia, RFC 4180

Constructor Summary
CSVParser()
          Constructor with default delimiter (,) and trimFields (true).
CSVParser(char delimiter, boolean trimFields)
          Constructs the parser with specified options
 
Method Summary
 List<String> tokenize(String line)
          Assumes this is one line of CSV text
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVParser

public CSVParser()
Constructor with default delimiter (,) and trimFields (true).


CSVParser

public CSVParser(char delimiter,
                 boolean trimFields)
Constructs the parser with specified options

Parameters:
delimiter - field separator character (e.g. comma, tab, vertical bar / pipe, space)
trimFields - indicates if fields are to be trimmed or not
Method Detail

tokenize

public List<String> tokenize(String line)
                      throws ParseException
Assumes this is one line of CSV text

Parameters:
line - line of text to parse
Returns:
list of tokens/fields; never returns null
Throws:
ParseException - if
  1. carriage return/newline found outside of a double quote, and
  2. terminating double quote not found

-bottom