// This class is public so that tools can invoke. publicclass TextFileReader implements AutoCloseable { private BufferedReader reader; privateint lineNo;
public TextFileReader(File file) throws IOException {
InputStream is = new FileInputStream(file);
reader = new BufferedReader(new InputStreamReader(is, "utf-8"));
}
public String readLine() throws IOException { return getLine();
}
public String getLine() throws IOException {
checkReader();
String line; while ((line = reader.readLine()) != null) {
lineNo++;
line = line.trim(); // Skip blank and comment lines. if (line.length() == 0) { continue;
} int x = line.indexOf('#'); if (x == 0) { continue;
} if (x > 0) {
line = line.substring(0, x).trim();
} break;
} return line;
}
public String getRawLine() throws IOException {
checkReader();
String line = reader.readLine(); if (line != null) {
lineNo++;
} return line;
}
privatevoid checkReader() throws IOException { if (reader == null) { thrownew IOException("This TextFileReader has been closed.");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.