类初始化期间ImageIO中的java.lang.NumberFormatException

时间:2018-06-18 19:16:07

标签: java bufferedimage javax.imageio

任何人都可以帮我解决这个错误:

我只是想打开一个图像文件。文件存在且文件路径正确。

try {
    BufferedImage img = ImageIO.read(new File(path, "img.jpg"));    
    ....

} catch (Exception e) {e.printStackTrace();}

错误:

Caught and handled this exception :
java.lang.NumberFormatException: For input string: ""
    at java.base/java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.base/java.lang.Integer.parseInt(Unknown Source)
    at java.base/java.lang.Integer.parseInt(Unknown Source)
    at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
    at com.github.jaiimageio.impl.plugins.wbmp.WBMPImageReaderSpi.onRegistration(WBMPImageReaderSpi.java:96)
    at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(Unknown Source)
    at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(Unknown Source)
    at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(Unknown Source)
    at java.desktop/javax.imageio.spi.IIORegistry.<init>(Unknown Source)
    at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(Unknown Source)
    at java.desktop/javax.imageio.ImageIO.<clinit>(Unknown Source)
    at abhi.Abhi.main(Abhi.java:496)

0 个答案:

没有答案