gpt4 book ai didi

java - ImageIO.createImageInputStream 无法在 Java 平台 se 7 上运行

转载 作者:行者123 更新时间:2023-11-30 11:38:36 28 4
gpt4 key购买 nike

下面的代码在以前的版本中运行良好,但在升级到 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.jpgException 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)

最佳答案

我在这里回答了一个基本相同的问题:ImageIO methods not working after switching to Java 7 .

唯一的区别是,此异常是由 ImageInputStreamSpi 尝试注册为 ImageReaderSpi 引起的。

关于java - ImageIO.createImageInputStream 无法在 Java 平台 se 7 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13577345/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com