如何拨打setInput
班级的ImageReader
?
以下是我的代码:
ImageInputStream iis = ImageIO.createImageInputStream(newByteArrayInputStream(cipherData));
Iterator<ImageReader> readers=ImageIO.getImageReaders(iis);
Iterator<ImageReader> readers=ImageIO.getImageReaders(iis);
System.out.println("readers="+readers);
答案 0 :(得分:1)
如果您的意思是调用读者变量中包含的ImageReader
s上的方法,则可以循环使用它们:
for (Iterator<ImageReader> it=ImageIO.getImageReaders(iis); it.hasNext();) {
ImageReader reader = it.next();
readers.setInput(someObject);
}
修改强>
如果您只想要第一个元素:
Iterator<ImageReader> it=ImageIO.getImageReaders(iis);
ImageReader reader = null;
if (it.hasNext()) {
reader = it.next();
}
//you probably want to check for null here to make sure there was one element