public class LineIterator
extends java.lang.Object
implements java.util.Iterator<java.lang.String>, java.io.Closeable
This class change the contract of hasNext() method by
throwing RuntimeIOException on IOException.
Decorators should override format(String) method.
This class is not threadsafe.
PropertiesSubstitutor| Constructor and Description |
|---|
LineIterator(java.io.Reader reader) |
LineIterator(java.io.Reader reader,
PropertiesSubstitutor substitutor) |
LineIterator(java.io.Reader reader,
PropertiesSubstitutor substitutor,
boolean trimLines)
Constructs iterator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected java.lang.String |
format(java.lang.String line)
Applies additional formatting to the line read.
|
java.lang.String |
getLineAt(int n)
Returns specified line or null if EOF occured.
|
boolean |
hasNext() |
java.lang.String |
next()
Returns the next avalable line in a reader.
|
void |
remove() |
int |
skip(int n)
Skips N lines.
|
public LineIterator(java.io.Reader reader)
public LineIterator(java.io.Reader reader,
PropertiesSubstitutor substitutor)
public LineIterator(java.io.Reader reader,
PropertiesSubstitutor substitutor,
boolean trimLines)
reader - reader to iterate.substitutor - substitutor to use to expand properties or null to disable substitution.trimLines - true if the returned lines should be trimmed.public boolean hasNext()
throws RuntimeIOException
hasNext in interface java.util.Iterator<java.lang.String>next()RuntimeIOException - if IO error occurs.protected java.lang.String format(java.lang.String line)
May be overriden by decorators.
line - line of text, nulls allowed.public java.lang.String next()
throws RuntimeIOException,
java.util.NoSuchElementException
next in interface java.util.Iterator<java.lang.String>RuntimeIOException - if IO error occurs.java.util.NoSuchElementException - if has no more elements.public int skip(int n)
n - number of lines to skip.public java.lang.String getLineAt(int n)
n - line number relative to the current line in the input. n>=0public void remove()
throws java.lang.UnsupportedOperationException
remove in interface java.util.Iterator<java.lang.String>java.lang.UnsupportedOperationExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionCopyright © Copyright 2006-2019 The Scriptella Project Team.