public class CSVReader extends AbstractDataReader
Class that creates a DataSource
from file contents which are
separated by a certain delimiter character. The delimiter is chosen based on
the file type but can also be set manually. By default the comma character
will be used as a delimiter for separating columns.
CSVReader
instances should be obtained by the
DataReaderFactory
rather than being created manually:
DataReaderFactory factory = DataReaderFactory.getInstance(); DataReader reader = factory.get("text/csv"); reader.read(new FileInputStream(filename), Integer.class, Double.class);
Modifier and Type | Field and Description |
---|---|
static String |
SEPARATOR_CHAR
Key for specifying a
Character value that defines the
delimiting character used to separate columns. |
Constructor and Description |
---|
CSVReader(String mimeType)
Creates a new instance with the specified MIME type.
|
Modifier and Type | Method and Description |
---|---|
DataSource |
read(InputStream input,
Class<? extends Comparable<?>>... types)
Returns a DataSource that was imported.
|
getMimeType, getSetting, setDefault, setSetting
addCapabilities, getCapabilities
public static final String SEPARATOR_CHAR
Character
value that defines the
delimiting character used to separate columns.public CSVReader(String mimeType)
mimeType
- MIME type of the file format to be read.public DataSource read(InputStream input, Class<? extends Comparable<?>>... types) throws IOException
input
- Input to be read.types
- Number types for the columns of the DataSource.IOException
- when the file format is not valid or when
experiencing an error during file operations.Copyright © 2009-2013. All Rights Reserved.