CSVTokenizer

public class CSVTokenizer

CSVTokenizer is a tokenizer which can parses a given CSV and represent its content as multiple rows and columns.

Author:Hugo Y. K. Lam

Constructors

CSVTokenizer

public CSVTokenizer(Reader csv)

Creates a new instance of CSVTokenizer.

Parameters:
  • csv – the CSV content.
Throws:
  • IOException – if unable to read the content from the given reader.

CSVTokenizer

public CSVTokenizer(String csv)

Creates a new instance of CSVTokenizer.

Parameters:
  • csv – the CSV content.

Methods

getColumn

public String getColumn(int pos)

Gets a column’s value.

Parameters:
  • pos – the position of the column.
Returns:

the specified column’s value.

getColumnCount

public int getColumnCount()

Gets the number of columns in the current row.

Returns:the number of columns.

hasMoreRows

public boolean hasMoreRows()

Checks if there are any more rows in this tokenizer.

Returns:true if there are more rows in this tokenizer.

nextRow

public void nextRow()

Proceeds to tokenize the next row.