// test ImageReader.getNumImages() for all available ImageReaders, // with no source set
Iterator readerspis = registry.getServiceProviders(ImageReaderSpi.class, false); while (readerspis.hasNext()) { boolean caughtEx = false;
ImageReaderSpi readerspi = (ImageReaderSpi)readerspis.next();
ImageReader reader = readerspi.createReaderInstance(); try {
reader.getNumImages(false);
} catch (IllegalStateException ise) { // caught exception, everything's okay
caughtEx = true;
}
if (!caughtEx) { thrownew RuntimeException("Test failed: exception was not " + "thrown for null input: " +
reader);
}
}
// test ImageReader.getNumImages() for all available ImageReaders, // with source set, seekForwardOnly and allowSearch both true
readerspis = registry.getServiceProviders(ImageReaderSpi.class, false); while (readerspis.hasNext()) { boolean caughtEx = false;
ImageReaderSpi readerspi = (ImageReaderSpi)readerspis.next();
ImageReader reader = readerspi.createReaderInstance(); byte[] barr = newbyte[100];
ByteArrayInputStream bais = new ByteArrayInputStream(barr);
ImageInputStream iis = ImageIO.createImageInputStream(bais); try {
reader.setInput(iis, true);
reader.getNumImages(true);
} catch (IllegalStateException ise) { // caught exception, everything's okay
caughtEx = true;
}
if (!caughtEx) { thrownew RuntimeException("Test failed: exception was not " + "thrown when allowSearch and " + "seekForwardOnly are both true: " +
reader);
}
}
}
}
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.