olg.csv.base.csv
Class CSVReader

java.lang.Object
  extended by olg.csv.base.csv.CSVReader
All Implemented Interfaces:
Closeable, Iterator<Row>, IReader

public final class CSVReader
extends Object
implements IReader

CSV Reader. CSV Implementation of IReader.


Constructor Summary
  CSVReader(File file, CSVSettings settings)
          Constructor with custom settings.
protected CSVReader(File file, CSVSettings settings, int bufSize)
          Constructor with custom settings.
  CSVReader(InputStream input, CSVSettings settings)
          Constructor with custom settings.
 
Method Summary
 void close()
          Closes this stream and catches and logs IOException. if the parent stream is provided and passed to CSVReader constructor by user, user must close it (closes what you opens!)
 boolean hasNext()
          
 boolean isWithHeaders()
          Indicates the CSV file has a header line.
 Row next()
          
 void remove()
           CSVReader throws an UnsupportedOperationException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVReader

public CSVReader(File file,
                 CSVSettings settings)
          throws IOException
Constructor with custom settings.

throws UnsupportedCharsetException if charset is not supported.

throws FileNotFoundException if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.

throws IllegalArgumentException if file, CSVSettings, lineSeparator setting or charsetName setting is null

Parameters:
file - the file to be read.
settings - the settings.
Throws:
IOException - if error occurs on file opening.
See Also:
to see default parameters values

CSVReader

protected CSVReader(File file,
                    CSVSettings settings,
                    int bufSize)
             throws IOException
Constructor with custom settings.

throws UnsupportedCharsetException if charset is not supported.

throws FileNotFoundException if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.

Parameters:
file - the file.
settings - the settings
bufSize - the buffer size.
Throws:
IOException - if error occurs on file opening.
See Also:
to see default parameters values

CSVReader

public CSVReader(InputStream input,
                 CSVSettings settings)
          throws IOException
Constructor with custom settings.

throws UnsupportedCharsetException if charset is not supported.

throws IllegalArgumentException if input, CSVSettings or charsetName setting is null

Parameters:
input - the stream
settings - the settings.
Throws:
IOException - if error occurs on stream buffering.
See Also:
to see default parameters values
Method Detail

isWithHeaders

public boolean isWithHeaders()
Indicates the CSV file has a header line.

Specified by:
isWithHeaders in interface IReader
Returns:
if the CSV file has a header line.

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator<Row>

next

public Row next()

Specified by:
next in interface Iterator<Row>

remove

public void remove()
CSVReader throws an UnsupportedOperationException.

Specified by:
remove in interface Iterator<Row>

close

public void close()
Closes this stream and catches and logs IOException. if the parent stream is provided and passed to CSVReader constructor by user, user must close it (closes what you opens!)

Specified by:
close in interface Closeable


Copyright © 2014. All rights reserved.