Class CSVReader
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.util.csv.CSVReader
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable
 
 public class CSVReader extends java.lang.Object implements java.io.CloseableA very simple CSV reader released under a commercial-friendly license.
- 
- 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_SKIP_LINESThe default line to start reading.
 - 
Constructor SummaryConstructors Constructor Description CSVReader(java.io.Reader reader)Constructs CSVReader using a comma for the separator.CSVReader(java.io.Reader reader, char separator)Constructs CSVReader with supplied separator.CSVReader(java.io.Reader reader, char separator, char quotechar)Constructs CSVReader with supplied separator and quote char.CSVReader(java.io.Reader reader, char separator, char quotechar, boolean strictQuotes)Constructs CSVReader with supplied separator, quote char and quote handling behavior.CSVReader(java.io.Reader reader, char separator, char quotechar, char escape)Constructs CSVReader with supplied separator and quote char.CSVReader(java.io.Reader reader, char separator, char quotechar, char escape, int line)Constructs CSVReader with supplied separator and quote char.CSVReader(java.io.Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes)Constructs CSVReader with supplied separator and quote char.CSVReader(java.io.Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)Constructs CSVReader with supplied separator and quote char.CSVReader(java.io.Reader reader, char separator, char quotechar, int line)Constructs CSVReader with supplied separator and quote char.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying reader.java.util.List<java.lang.String[]>readAll()Reads the entire file into a List with each element being a String[] of tokens.java.lang.String[]readNext()Reads the next line from the buffer and converts to a string array.
 
- 
- 
- 
Field Detail- 
DEFAULT_SKIP_LINESpublic static final int DEFAULT_SKIP_LINES The default line to start reading.- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
CSVReaderpublic CSVReader(java.io.Reader reader) Constructs CSVReader using a comma for the separator.- Parameters:
- reader- the reader to an underlying CSV source.
 
 - 
CSVReaderpublic CSVReader(java.io.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.
 
 - 
CSVReaderpublic CSVReader(java.io.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 entries
- quotechar- the character to use for quoted elements
 
 - 
CSVReaderpublic CSVReader(java.io.Reader reader, char separator, char quotechar, boolean strictQuotes)Constructs CSVReader with supplied separator, quote char and quote handling behavior.- Parameters:
- reader- the reader to an underlying CSV source.
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
- strictQuotes- sets if characters outside the quotes are ignored
 
 - 
CSVReaderpublic CSVReader(java.io.Reader reader, char separator, char quotechar, char escape)Constructs CSVReader with supplied separator and quote char.- Parameters:
- reader- the reader to an underlying CSV source.
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
- escape- the character to use for escaping a separator or quote
 
 - 
CSVReaderpublic CSVReader(java.io.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 entries
- quotechar- the character to use for quoted elements
- line- the line number to skip for start reading
 
 - 
CSVReaderpublic CSVReader(java.io.Reader reader, char separator, char quotechar, char escape, 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 entries
- quotechar- the character to use for quoted elements
- escape- the character to use for escaping a separator or quote
- line- the line number to skip for start reading
 
 - 
CSVReaderpublic CSVReader(java.io.Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes)Constructs CSVReader with supplied separator and quote char.- Parameters:
- reader- the reader to an underlying CSV source.
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
- escape- the character to use for escaping a separator or quote
- line- the line number to skip for start reading
- strictQuotes- sets if characters outside the quotes are ignored
 
 - 
CSVReaderpublic CSVReader(java.io.Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace)Constructs CSVReader with supplied separator and quote char.- Parameters:
- reader- the reader to an underlying CSV source.
- separator- the delimiter to use for separating entries
- quotechar- the character to use for quoted elements
- escape- the character to use for escaping a separator or quote
- line- the line number to skip for start reading
- strictQuotes- sets if characters outside the quotes are ignored
- ignoreLeadingWhiteSpace- it true, parser should ignore white space before a quote in a field
 
 
- 
 - 
Method Detail- 
readAllpublic java.util.List<java.lang.String[]> readAll() throws java.io.IOExceptionReads 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:
- java.io.IOException- if bad things happen during the read
 
 - 
readNextpublic java.lang.String[] readNext() throws java.io.IOExceptionReads 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:
- java.io.IOException- if bad things happen during the read
 
 - 
closepublic void close() throws java.io.IOExceptionCloses the underlying reader.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Throws:
- java.io.IOException- if the close fails
 
 
- 
 
-