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 void
close()
long
getOffset()
Returns the current opaque offset within the underlying data streamboolean
hasNext()
java.lang.String
next()
void
remove()
-
-
-
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:
hasNext
in interfacejava.util.Iterator<java.lang.String>
-
next
public java.lang.String next()
- Specified by:
next
in interfacejava.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 interfaceOffsetIterator<java.lang.String>
- Returns:
- offset in bytes
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<java.lang.String>
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-