Top Description Fields Constructors Methods
com.opencsv

public Class CSVIterator

extends Object
implements Iterator<String[]>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Imports
com.opencsv.exceptions.CsvValidationException, org.apache.commons.lang3.ObjectUtils, java.io.IOException, java.util.Iterator, .Locale, .NoSuchElementException, .ResourceBundle

Provides an Iterator over the data found in opencsv.

Fair warning! This mechanism of getting at the data opencsv delivers has limitations when used with the opencsv annotations. Locales and custom converters are not supported. Further features may or may not work.

Field Summary

Modifier and TypeField and Description
private Locale
errorLocale

Locale for all translations.

private String[]
private final CSVReader

Constructor Summary

AccessConstructor and Description
public
CSVIterator(CSVReader
Reader for the CSV data.
reader
)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

True if the CSVIterator has more elements.
hasNext
()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public String[]

Returns:

The next element of the iterator.
next
()

Implements java.util.Iterator.next.

Returns the next element in the iterator.

public void
remove()

Overrides default java.util.Iterator.remove.

This method is not supported by opencsv and will throw an java.lang.UnsupportedOperationException if called.

public void
setErrorLocale(Locale
Locale for error messages. If null, the default locale is used.
errorLocale
)

Sets the locale for error messages.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorLocaleback to summary
private Locale errorLocale

Locale for all translations.

nextLineback to summary
private String[] nextLine
readerback to summary
private final CSVReader reader

Constructor Detail

CSVIteratorback to summary
public CSVIterator(CSVReader reader) throws IOException, CsvValidationException
Parameters
reader:CSVReader

Reader for the CSV data.

Exceptions
IOException:
If unable to read data from the reader.
CsvValidationException:
if custom defined validator fails.

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements. In other words, returns true if next() would return an element rather than throwing an exception.

Returns:boolean

True if the CSVIterator has more elements.

Annotations
@Override
nextback to summary
public String[] next()

Implements java.util.Iterator.next.

Returns the next element in the iterator.

Returns:String[]

The next element of the iterator.

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

This method is not supported by opencsv and will throw an java.lang.UnsupportedOperationException if called.

Annotations
@Override
setErrorLocaleback to summary
public void setErrorLocale(Locale errorLocale)

Sets the locale for error messages.

Parameters
errorLocale:Locale

Locale for error messages. If null, the default locale is used.

Since
4.0