public class CSVDataSource extends Object
| Constructor and Description |
|---|
CSVDataSource() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
getBoolean(String columnName) |
boolean |
getBoolean(String columnName,
boolean defaultValue) |
int |
getInt(String columnName) |
int |
getInt(String columnName,
int defaultValue) |
String |
getString(int columnIndex)
Get a string-typed value by column index.
|
String |
getString(int columnIndex,
String defaultValue)
Get a string-typed value by column index.
|
String |
getString(String columnName)
Get a string-typed value by column name.
|
String |
getString(String columnName,
String defaultValue)
Get a string-typed value by column name.
|
boolean |
isEndOfFile()
Indicates whether the end of the file has been reached.
|
void |
next()
Advance to the next row, if any.
|
void |
openForReading(Reader in)
Open a CSV formatted character stream for reading.
|
void |
openForWriting(Writer out,
String... columnNames)
Open a CSV formatted character stream for writing.
|
void |
setBoolean(String columnName,
boolean value) |
void |
setInt(String columnName,
int value) |
void |
setString(int columnIndex,
String value)
Set a string-typed value by column index.
|
void |
setString(String columnName,
String value)
Set a string-typed value by column name.
|
public void openForReading(Reader in) throws IOException
CSVDataSource that has been used for reading once cannot be
reused.in - The character stream to read.IOException - If an I/O error occurs reading the headers or the
first row of data.public void openForWriting(Writer out, String... columnNames) throws IOException
CSVDataSource that has been used for writing once cannot be
reused.out - The character stream to write to.columnNames - The names of all the columns that will be written.IOException - If an I/O error occurs writing the headers.public boolean isEndOfFile()
true if the end of the file has been reached.public void next()
throws IOException
isEndOfFile() should be
invoked afterwards, and before trying to get data, to determine whether
the end of the file had been reached.IOException - If an I/O error occurs reading from or writing to the
stream.public String getString(String columnName)
columnName - The name of the column.public String getString(String columnName, String defaultValue)
columnName - The name of the column.defaultValue - The value to return if the specified column is not present, or the value is not set.public String getString(int columnIndex)
columnIndex - The index of the column.public String getString(int columnIndex, String defaultValue)
columnIndex - The index of the column.defaultValue if the column does not
exist or the value is not set.public void setString(String columnName, String value)
null values are
supported but are converted into empty strings.columnName - The name of the column.value - The value to store in the column.public void setString(int columnIndex,
String value)
null values are
supported but are converted into empty strings.columnIndex - The index of the column.value - The value to store in the column.public int getInt(String columnName)
public int getInt(String columnName, int defaultValue)
public void setInt(String columnName, int value)
public boolean getBoolean(String columnName)
public boolean getBoolean(String columnName, boolean defaultValue)
public void setBoolean(String columnName, boolean value)
Copyright © 2011–2025 pepsoft.org. All rights reserved.