以下代码适用于以前的版本,但在升级到Java 7后无法正常工作。
有人可以帮忙吗?
代码:
if (imageFile.exists())
System.out.println(imageFile.getPath()+" :"+ imageFile.getName());
// prepare to read the input
final FileInputStream fis = new FileInputStream (imageFile);
ImageInputStreamiis=null;
iis = ImageIO.createImageInputStream(fis);
final Iterator<ImageReader> imageReaders = ImageIO.getImageReaders(iis);
ImageReader reader = imageReaders.next();
reader.setInput(iis, true, false);
Errors: C:\Users\apps\Documents\DSC_1244.jpg :DSC_1244.jpg Exception in thread "AWT-EventQueue-0" java.util.ServiceConfigurationError: javax.imageio.spi.ImageReaderSpi: Provider it.tidalwave.imageio.io.FileImageInputStream2Spi not a subtype at java.util.ServiceLoader.fail(ServiceLoader.java:231) at java.util.ServiceLoader.access$300(ServiceLoader.java:181) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:369) at java.util.ServiceLoader$1.next(ServiceLoader.java:445) at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:210) at javax.imageio.spi.IIORegistry.(IIORegistry.java:138) at javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:159) at javax.imageio.ImageIO.(ImageIO.java:65) at hk.dawntech.digps2map.PhotoManagerImagePreview.paint(PhotoManagerImagePreview.java:50) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482) at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1413) at javax.swing.RepaintManager.paint(RepaintManager.java:1206) at javax.swing.JComponent._paintImmediately(JComponent.java:5169) at javax.swing.JComponent.paintImmediately(JComponent.java:4980) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728) at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677) at javax.swing.RepaintManager.access$700(RepaintManager.java:59) at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:682) at java.awt.EventQueue$3.run(EventQueue.java:680) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:691) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139) at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
答案 0 :(得分:1)
我在这里回答了一个基本相同的问题:ImageIO methods not working after switching to Java 7。
唯一的区别是此异常是由ImageInputStreamSpi
尝试注册为ImageReaderSpi
引起的。