Package io.ebeaninternal.server.text.csv
Class CsvUtilReader
- java.lang.Object
-
- io.ebeaninternal.server.text.csv.CsvUtilReader
-
public class CsvUtilReader extends Object
Glen Smith's CSV reader released under Apache License version 2.- Author:
- Glen Smith
-
-
Field Summary
Fields Modifier and Type Field Description static char
DEFAULT_QUOTE_CHARACTER
The default quote character to use if none is supplied to the constructor.static char
DEFAULT_SEPARATOR
The default separator to use if none is supplied to the constructor.static int
DEFAULT_SKIP_LINES
The default line to start reading.
-
Constructor Summary
Constructors Constructor Description CsvUtilReader(Reader reader)
Constructs CSVReader using a comma for the separator.CsvUtilReader(Reader reader, char separator)
Constructs CSVReader with supplied separator.CsvUtilReader(Reader reader, char separator, char quotechar)
Constructs CSVReader with supplied separator and quote char.CsvUtilReader(Reader reader, char separator, char quotechar, int line)
Constructs CSVReader with supplied separator and quote char.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the underlying reader.List<String[]>
readAll()
Reads the entire file into a List with each element being a String[] of tokens.String[]
readNext()
Reads the next line from the buffer and converts to a string array.
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATOR
The default separator to use if none is supplied to the constructor.- See Also:
- Constant Field Values
-
DEFAULT_QUOTE_CHARACTER
public static final char DEFAULT_QUOTE_CHARACTER
The default quote character to use if none is supplied to the constructor.- See Also:
- Constant Field Values
-
DEFAULT_SKIP_LINES
public static final int DEFAULT_SKIP_LINES
The default line to start reading.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CsvUtilReader
public CsvUtilReader(Reader reader)
Constructs CSVReader using a comma for the separator.- Parameters:
reader
- the reader to an underlying CSV source.
-
CsvUtilReader
public CsvUtilReader(Reader reader, char separator)
Constructs CSVReader with supplied separator.- Parameters:
reader
- the reader to an underlying CSV source.separator
- the delimiter to use for separating entries.
-
CsvUtilReader
public CsvUtilReader(Reader reader, char separator, char quotechar)
Constructs CSVReader with supplied separator and quote char.- Parameters:
reader
- the reader to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elements
-
CsvUtilReader
public CsvUtilReader(Reader reader, char separator, char quotechar, int line)
Constructs CSVReader with supplied separator and quote char.- Parameters:
reader
- the reader to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsline
- the line number to skip for start reading
-
-
Method Detail
-
readAll
public List<String[]> readAll() throws IOException
Reads the entire file into a List with each element being a String[] of tokens.- Returns:
- a List of String[], with each String[] representing a line of the file.
- Throws:
IOException
- if bad things happen during the read
-
readNext
public String[] readNext() throws IOException
Reads the next line from the buffer and converts to a string array.- Returns:
- a string array with each comma-separated element as a separate entry.
- Throws:
IOException
- if bad things happen during the read
-
close
public void close() throws IOException
Closes the underlying reader.- Throws:
IOException
- if the close fails
-
-