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
-
Method Summary
Modifier and TypeMethodDescriptioncommentPrefix
(String commentPrefix) Configures the prefix string used to identify comment lines.boolean
hasNext()
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.long
transferTo
(Writer out) trim()
Configures this reader to trim any leading and trailing whitespace from each line.static LineReader
Wraps the given reader in a line reader.Methods inherited from class java.io.BufferedReader
close, lines, mark, markSupported, read, read, ready, reset, skip
Methods inherited from class java.io.Reader
nullReader, read, read
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods 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:
readLine
in classBufferedReader
- Throws:
IOException
-
iterator
-
hasNext
public boolean hasNext() -
next
-
transferTo
- Overrides:
transferTo
in classReader
- Throws:
IOException
-
last
Returns the last line in the reader, skipping any intermediate lines.- Returns:
- the last line
-