Package org.moeaframework.util.io
Class LineReader
java.lang.Object
java.io.Reader
java.io.BufferedReader
org.moeaframework.util.io.LineReader
Read lines from a character-input stream, with options to ignore blank and commented lines.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncommentPrefix(String commentPrefix) Configures the prefix string used to identify comment lines.booleanhasNext()iterator()last()Returns the last line in the reader, skipping any intermediate lines.next()readLine()Configures this reader to skip any lines that contain only whitespace.Configures this reader to skip any lines starting with the comment prefix.longtransferTo(Writer out) trim()Configures this reader to trim any leading and trailing whitespace from each line.static LineReaderWraps the given reader in a line reader.Methods inherited from class java.io.BufferedReader
close, lines, mark, markSupported, read, read, ready, reset, skipMethods inherited from class java.io.Reader
nullReader, read, readMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
LineReader
Constructs a new line reader.- Parameters:
in- a reader
-
-
Method Details
-
wrap
Wraps the given reader in a line reader.- Parameters:
reader- the reader- Returns:
- the reader wrapped in a line reader
-
skipComments
Configures this reader to skip any lines starting with the comment prefix.- Returns:
- a reference to this reader
-
skipBlanks
Configures this reader to skip any lines that contain only whitespace.- Returns:
- a reference to this reader
-
trim
Configures this reader to trim any leading and trailing whitespace from each line.- Returns:
- a reference to this reader
-
commentPrefix
Configures the prefix string used to identify comment lines.- Parameters:
commentPrefix- the prefix string used to identify comments- Returns:
- a reference to this reader
-
readLine
- Overrides:
readLinein classBufferedReader- Throws:
IOException
-
iterator
-
hasNext
public boolean hasNext() -
next
-
transferTo
- Overrides:
transferToin classReader- Throws:
IOException
-
last
Returns the last line in the reader, skipping any intermediate lines.- Returns:
- the last line
-