Package cdc.util.csv
Class CsvParser
- java.lang.Object
-
- cdc.util.csv.CsvParser
-
public class CsvParser extends Object
Parsing of csv files. Special handling of text is done. However, one must not use '"' as a field separator. One must indicate whether the file has a header or not (this information is not automatically elaborated).- Author:
- Damien Carbonne
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CsvParsercountRows(boolean countRows)voidparse(File file, TableHandler handler, int headers)Parses a file using default charset.voidparse(File file, String charset, TableHandler handler, int headers)Parses a file.voidparse(InputStream in, TableHandler handler, int headers)Parses an InputStream using default charset.voidparse(InputStream in, String charset, TableHandler handler, int headers)Parses an InputStream.voidparse(Reader reader, TableHandler handler, int headers)Parses a Reader.CsvParsersetSeparator(char separator)Sets the used separator.voidsetVerbose(boolean verbose)Sets the verbosity level of the parser.(package private) CsvParsersetVoidHandler()
-
-
-
Method Detail
-
setSeparator
public CsvParser setSeparator(char separator)
Sets the used separator.- Parameters:
separator- the separator to use.- Returns:
- This parser.
-
countRows
public CsvParser countRows(boolean countRows)
-
setVoidHandler
CsvParser setVoidHandler()
-
setVerbose
public void setVerbose(boolean verbose)
Sets the verbosity level of the parser.- Parameters:
verbose- indicates whether the parsing must be verbose or not.
-
parse
public void parse(Reader reader, TableHandler handler, int headers) throws IOException
Parses a Reader.If
readersupports mark, the number of lines is computed.- Parameters:
reader- The reader to parse.handler- The table handler to use.headers- The number of header lines.- Throws:
IOException- When an IO exception occurs.
-
parse
public void parse(InputStream in, String charset, TableHandler handler, int headers) throws IOException
Parses an InputStream.- Parameters:
in- The input stream.charset- The charset to use.handler- The table handler to use.headers- The number of header lines.- Throws:
IOException- When an IO exception occurs.
-
parse
public void parse(InputStream in, TableHandler handler, int headers) throws IOException
Parses an InputStream using default charset.- Parameters:
in- The input stream.handler- The table handler to use.headers- The number of header lines.- Throws:
IOException- When an IO exception occurs.
-
parse
public void parse(File file, String charset, TableHandler handler, int headers) throws IOException
Parses a file.- Parameters:
file- The input file.charset- The charset to use.handler- The table handler to use.headers- The number of header lines.- Throws:
IOException- When an IO exception occurs.
-
parse
public void parse(File file, TableHandler handler, int headers) throws IOException
Parses a file using default charset.- Parameters:
file- The input file.handler- The table handler to use.headers- The number of header lines.- Throws:
IOException- When an IO exception occurs.
-
-