Class StreamLineIterator

  • All Implemented Interfaces:
    OffsetIterator<java.lang.String>, java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator<java.lang.String>

    public class StreamLineIterator
    extends java.lang.Object
    implements OffsetIterator<java.lang.String>
    Iterate the lines in a stream or file, provide offset location of the current read position, supports file stream which already has an offset
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamLineIterator​(java.io.FileInputStream raf, java.lang.String encoding)  
      StreamLineIterator​(java.io.InputStream stream, java.lang.String encoding)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      long getOffset()
      Returns the current opaque offset within the underlying data stream
      boolean hasNext()  
      java.lang.String next()  
      void remove()  
      • 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

      • StreamLineIterator

        public StreamLineIterator​(java.io.FileInputStream raf,
                                  java.lang.String encoding)
                           throws java.io.IOException
        Parameters:
        raf - file steram
        encoding - optional encoding
        Throws:
        java.io.IOException - on error
      • StreamLineIterator

        public StreamLineIterator​(java.io.InputStream stream,
                                  java.lang.String encoding)
                           throws java.io.IOException
        Parameters:
        stream - text stream
        encoding - encoding
        Throws:
        java.io.IOException - on error
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.String>
      • next

        public java.lang.String next()
        Specified by:
        next in interface java.util.Iterator<java.lang.String>
      • getOffset

        public long getOffset()
        Description copied from interface: OffsetIterator
        Returns the current opaque offset within the underlying data stream
        Specified by:
        getOffset in interface OffsetIterator<java.lang.String>
        Returns:
        offset in bytes
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<java.lang.String>
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException