jhplot.io.csv
Class CSVReader

java.lang.Object
  extended by jhplot.io.csv.CSVReader

public class CSVReader
extends java.lang.Object

A very simple CSV reader released under a commercial-friendly license.


Field Summary
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
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, int line)
          Constructs CSVReader with supplied separator and quote char.
CSVReader(java.lang.String file)
          Constructs CSVReader using a comma for the separator.
CSVReader(java.lang.String file, char separator)
          Constructs CSVReader with supplied separator.
CSVReader(java.lang.String file, char separator, char quotechar)
          Constructs CSVReader with supplied separator and quote char.
CSVReader(java.lang.String file, char separator, char quotechar, int line)
          Constructs CSVReader with supplied separator and quote char.
 
Method Summary
 void close()
          Closes the underlying reader.
 void doc()
          Show online documentation.
 java.util.ArrayList<java.lang.String> next()
          Reads the next line from the buffer and converts to a string List.
 java.util.ArrayList<java.lang.String[]> readAll()
          Reads the entire file into a List with each element being a String[] of tokens.
 java.util.ArrayList<java.util.ArrayList> readList()
          Reads the entire file into a List with each element being a List of tokens.
 java.lang.String[] readNext()
          Reads the next line from the buffer and converts to a string array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

CSVReader

public CSVReader(java.io.Reader reader)
Constructs CSVReader using a comma for the separator.

Parameters:
reader - the reader to an underlying CSV source.

CSVReader

public CSVReader(java.lang.String file)
Constructs CSVReader using a comma for the separator.

Parameters:
file - file with an underlying CSV source.

CSVReader

public 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.

CSVReader

public CSVReader(java.lang.String file,
                 char separator)
Constructs CSVReader with supplied separator.

Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries.

CSVReader

public 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

CSVReader

public CSVReader(java.lang.String file,
                 char separator,
                 char quotechar)
Constructs CSVReader with supplied separator and quote char.

Parameters:
file - file with an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements

CSVReader

public 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

CSVReader

public CSVReader(java.lang.String file,
                 char separator,
                 char quotechar,
                 int line)
Constructs CSVReader with supplied separator and quote char.

Parameters:
file - file with 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
Method Detail

doc

public void doc()
Show online documentation.


readAll

public java.util.ArrayList<java.lang.String[]> readAll()
                                                throws java.io.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:
java.io.IOException - if bad things happen during the read

readList

public java.util.ArrayList<java.util.ArrayList> readList()
                                                  throws java.io.IOException
Reads the entire file into a List with each element being a List of tokens.

Returns:
a List of List, with each List representing a line of the file.
Throws:
java.io.IOException - if bad things happen during the read

readNext

public java.lang.String[] readNext()
                            throws java.io.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:
java.io.IOException - if bad things happen during the read

next

public java.util.ArrayList<java.lang.String> next()
                                           throws java.io.IOException
Reads the next line from the buffer and converts to a string List.

Returns:
a string List with each comma-separated element as a separate entry.
Throws:
java.io.IOException - if bad things happen during the read

close

public void close()
           throws java.io.IOException
Closes the underlying reader.

Throws:
java.io.IOException - if the close fails


jHepWork 2.1 (C) S.Chekanov