Package com.opencsv

Class CSVIterator

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.String[]>

    public class CSVIterator
    extends java.lang.Object
    implements java.util.Iterator<java.lang.String[]>
    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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Returns true if the iteration has more elements.
      java.lang.String[] next()
      Returns the next element in the iterator.
      void remove()
      This method is not supported by opencsv and will throw an UnsupportedOperationException if called.
      void setErrorLocale​(java.util.Locale errorLocale)
      Sets the locale for error messages.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • CSVIterator

        public CSVIterator​(CSVReader reader)
                    throws java.io.IOException,
                           CsvValidationException
        Parameters:
        reader - Reader for the CSV data.
        Throws:
        java.io.IOException - If unable to read data from the reader.
        CsvValidationException - if custom defined validator fails.
    • Method Detail

      • setErrorLocale

        public void setErrorLocale​(java.util.Locale errorLocale)
        Sets the locale for error messages.
        Parameters:
        errorLocale - Locale for error messages. If null, the default locale is used.
        Since:
        4.0
      • hasNext

        public boolean 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.
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.String[]>
        Returns:
        True if the CSVIterator has more elements.
      • next

        public java.lang.String[] next()
        Returns the next element in the iterator.
        Specified by:
        next in interface java.util.Iterator<java.lang.String[]>
        Returns:
        The next element of the iterator.
      • remove

        public void remove()
        This method is not supported by opencsv and will throw an UnsupportedOperationException if called.
        Specified by:
        remove in interface java.util.Iterator<java.lang.String[]>