/** *ThisprogramcreatesaLineNumberReaderandtriestofindall *thenon-whitespacecharactersinthefile.
*/ publicstaticvoid main(String[] args) throws Exception { int n, line;
LineNumberReader reader = new LineNumberReader
(new StringReader("0\r\n1\r2\n3\r\n\r5\r\r7\n\n9")); for (n = 0; n < 7; n++) {
skipWhiteSpace(reader); /* Skip all whitespace */ int c = reader.read(); /* Read the non-whitespace character */ if (c < 0) { /* Might be eof */ break; /* It is. Get out of the loop */
}
line = reader.getLineNumber(); if(line != (c - 48)) { thrownew Exception("Failed test : Line number expected "
+ (c - 48) + " got " + line );
}
}
}
/** *Skipwhitespaceinthefile.Markandreset
*/ privatestaticvoid skipWhiteSpace(LineNumberReader reader) throws IOException { while (true) { /* Mark in case the character is not whitespace */
reader.mark(10); /* Read the character */ int c = reader.read(); if (Character.isWhitespace((char) c)) { /* Loop while in whitespace */ continue;
}
/* Return to the non-whitespace character */
reader.reset(); break;
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-09-29)
¤
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.