Java Reference
In-Depth Information
this.reader =
new BufferedReader(
new InputStreamReader(
inputStream, "UTF-8"
)
);
}
private void explodeIfException() {
if (exception != null) {
throw new UncheckedIOException("error reading the stream", exception);
}
}
/**
* Returns the next line of the text, filtering out whitespace, bad
* characters, comments, etc.
* Assigns {@link #nextElement} to the next line, or to {@code null} if
* there are no lines remaining.
*/
private String nextLine() {
explodeIfException();
if (closed) return nextElement = null;
try {
String line;
while ((line = reader.readLine()) != null) {
line = BAD_CHARS.matcher(line).replaceAll("");
line = line.trim();
if (line.isEmpty() || IS_WHITESPACE.test(line)) {
continue;
} else {
break;
}
}
if (line != null && IS_COMMENT_START.test(line)) {
while ((line = reader.readLine()) != null) {
if (IS_COMMENT_END.test(line)) break;
}
if (line != null) return nextLine();
}
if (line == null) {
reader.close();
closed = true;
}
Search WWH ::




Custom Search