publicstaticvoid main(String[] args) throws Exception {
genericTest();
testNegativePosition(); // This test for bug 4862382
testUnreadableChannel();// This test for bug 4862408
}
// This test for bug 4862382 privatestaticvoid testNegativePosition() throws Exception {
File blah = File.createTempFile("blah1", null);
blah.deleteOnExit();
FileOutputStream fos = new FileOutputStream(blah);
fos.write(newbyte[128]);
fos.close();
FileChannel fc = (new FileInputStream(blah)).getChannel(); try {
fc.read(ByteBuffer.allocate(256), -1L); thrownew RuntimeException("Expected exception not thrown");
} catch(IllegalArgumentException e) { // Correct result
} finally {
fc.close();
blah.delete();
}
}
// This test for bug 4862408 privatestaticvoid testUnreadableChannel() throws Exception {
File blah = File.createTempFile("blah2", null);
blah.deleteOnExit();
FileOutputStream fos = new FileOutputStream(blah); try {
fos.write(newbyte[128]);
FileChannel fc = fos.getChannel(); try {
fc.read(ByteBuffer.allocate(256),1); thrownew RuntimeException("Expected exception not thrown");
} catch(NonReadableChannelException e) { // Correct result
}
} finally {
fos.close();
blah.delete();
}
}
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.