Java Reference
In-Depth Information
private static Predicate<String> notEmptyOrWhitespace() {
return Pattern.compile("^\\s*$").asPredicate().negate();
* Provides a sequential stream of the text source. The stream is filtered
* of bad characters, whitespace lines, and comments. Each line is also
* trimmed.
* @return A stream, which must be processed sequentially
* @throws IOException If there is an exception getting the resource
public Stream<String> getStream() throws IOException {
return getReader().lines()
import java.util.*;
* A method representing a line in a text
public class TextLine {
private final String title;
private final int lineNumber;
private final String line;
private final int year;
public TextLine(
final String title, final int year,
final int lineNumber, final String line
) {
Objects.requireNonNull(title, "title");
this.title = title;
if (lineNumber < 1) {
throw new IllegalArgumentException(
"Line offset must be positive, but was " + lineNumber);
this.lineNumber = lineNumber;
Search WWH ::

Custom Search