Package com.dtolabs.utils
Class StreamLineIterator
- java.lang.Object
-
- com.dtolabs.utils.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 voidclose()longgetOffset()Returns the current opaque offset within the underlying data streambooleanhasNext()java.lang.Stringnext()voidremove()
-
-
-
Constructor Detail
-
StreamLineIterator
public StreamLineIterator(java.io.FileInputStream raf, java.lang.String encoding) throws java.io.IOException- Parameters:
raf- file steramencoding- 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 streamencoding- encoding- Throws:
java.io.IOException- on error
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<java.lang.String>
-
next
public java.lang.String next()
- Specified by:
nextin interfacejava.util.Iterator<java.lang.String>
-
getOffset
public long getOffset()
Description copied from interface:OffsetIteratorReturns the current opaque offset within the underlying data stream- Specified by:
getOffsetin interfaceOffsetIterator<java.lang.String>- Returns:
- offset in bytes
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<java.lang.String>
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-