publicclass Skip { publicstaticvoid main( String argv[] ) throws Exception {
StringReader in = new StringReader("1234567");
// Skip forward and read if (in.skip(3) != 3) thrownew RuntimeException("skip(3) failed"); if (in.read() != '4') thrownew RuntimeException("post skip read failure");
// Skip backward and read if (in.skip(-2) != -2) thrownew RuntimeException("skip(-2) failed"); if (in.read() != '3') thrownew RuntimeException("read failed after negative skip");
// Attempt to skip backward past the beginning and read if (in.skip(-6) != -3) thrownew RuntimeException("skip(-6) failed"); if (in.read() != '1') thrownew RuntimeException("read after skip past beginning failed");
// Skip beyond the end if (in.skip(30) != 6) thrownew RuntimeException("skip(30) failed"); if (in.read() != -1) thrownew RuntimeException("read at EOF failed");
// Test after reaching end of string if (in.skip(30) != 0) thrownew RuntimeException("skip(30) failed"); if (in.skip(-30) != 0) thrownew RuntimeException("skip(30) failed");
}
}
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.