下面列出了怎么用javax.imageio.spi.ImageInputStreamSpi的API类实例代码及写法,或者点击链接到github查看源代码。
public static void main(String[] args) throws IOException,
MalformedURLException {
/* deregister ImageOutputStreamSpi so that we creatImageOutputStream
* returns null while writing.
*/
localRegistry.deregisterAll(ImageOutputStreamSpi.class);
/* verify possible ImageIO.write() scenario's for null stream output
* from createImageOutputStream() API in ImageIO class.
*/
verifyFileWrite();
verifyStreamWrite();
/* deregister ImageInputStreamSpi so that we creatImageInputStream
* returns null while reading.
*/
localRegistry.deregisterAll(ImageInputStreamSpi.class);
/* verify possible ImageIO.read() scenario's for null stream output
* from createImageInputStream API in ImageIO class.
*/
verifyFileRead();
verifyStreamRead();
verifyUrlRead();
}
public static void main(String[] args) throws IOException,
MalformedURLException {
/* deregister ImageOutputStreamSpi so that we creatImageOutputStream
* returns null while writing.
*/
localRegistry.deregisterAll(ImageOutputStreamSpi.class);
/* verify possible ImageIO.write() scenario's for null stream output
* from createImageOutputStream() API in ImageIO class.
*/
verifyFileWrite();
verifyStreamWrite();
/* deregister ImageInputStreamSpi so that we creatImageInputStream
* returns null while reading.
*/
localRegistry.deregisterAll(ImageInputStreamSpi.class);
/* verify possible ImageIO.read() scenario's for null stream output
* from createImageInputStream API in ImageIO class.
*/
verifyFileRead();
verifyStreamRead();
verifyUrlRead();
}
public static void main(String[] args) throws IOException,
MalformedURLException {
/* deregister ImageOutputStreamSpi so that we creatImageOutputStream
* returns null while writing.
*/
localRegistry.deregisterAll(ImageOutputStreamSpi.class);
/* verify possible ImageIO.write() scenario's for null stream output
* from createImageOutputStream() API in ImageIO class.
*/
verifyFileWrite();
verifyStreamWrite();
/* deregister ImageInputStreamSpi so that we creatImageInputStream
* returns null while reading.
*/
localRegistry.deregisterAll(ImageInputStreamSpi.class);
/* verify possible ImageIO.read() scenario's for null stream output
* from createImageInputStream API in ImageIO class.
*/
verifyFileRead();
verifyStreamRead();
verifyUrlRead();
}
public static void main(String[] args) throws IOException,
MalformedURLException {
/* deregister ImageOutputStreamSpi so that we creatImageOutputStream
* returns null while writing.
*/
localRegistry.deregisterAll(ImageOutputStreamSpi.class);
/* verify possible ImageIO.write() scenario's for null stream output
* from createImageOutputStream() API in ImageIO class.
*/
verifyFileWrite();
verifyStreamWrite();
/* deregister ImageInputStreamSpi so that we creatImageInputStream
* returns null while reading.
*/
localRegistry.deregisterAll(ImageInputStreamSpi.class);
/* verify possible ImageIO.read() scenario's for null stream output
* from createImageInputStream API in ImageIO class.
*/
verifyFileRead();
verifyStreamRead();
verifyUrlRead();
}
public static void main(String[] args) throws IOException,
MalformedURLException {
/* deregister ImageOutputStreamSpi so that we creatImageOutputStream
* returns null while writing.
*/
localRegistry.deregisterAll(ImageOutputStreamSpi.class);
/* verify possible ImageIO.write() scenario's for null stream output
* from createImageOutputStream() API in ImageIO class.
*/
verifyFileWrite();
verifyStreamWrite();
/* deregister ImageInputStreamSpi so that we creatImageInputStream
* returns null while reading.
*/
localRegistry.deregisterAll(ImageInputStreamSpi.class);
/* verify possible ImageIO.read() scenario's for null stream output
* from createImageInputStream API in ImageIO class.
*/
verifyFileRead();
verifyStreamRead();
verifyUrlRead();
}
public static void main(String[] args) throws InterruptedException {
final ArrayList<Class<?>> services = new ArrayList<Class<?>>();
services.add(ImageInputStreamSpi.class);
final ServiceRegistry reg = new ServiceRegistry(services.iterator());
//create new thread for Registerer and Consumer Class
Thread registerer = new Thread(new Registerer(reg));
Thread consumer = new Thread(new Consumer(reg));
//run both registerer and consumer thread parallely
registerer.start();
consumer.start();
}
@Override
public void run() {
start = System.currentTimeMillis();
end = start + duration;
while (start < end) {
//access the ServiceProvider API
reg.getServiceProviders(ImageInputStreamSpi.class, true);
start = System.currentTimeMillis();
}
}