English 中文(简体)
图一
原标题:ImageIO Exception

I am getting the following error:

javax.imageio.IIOException: Can t read input file!
Resource not found: C:icon.gif
at javax.imageio.ImageIO.read(ImageIO.java:1301)
at connector.SystemTrayCreator.createImage(SystemTrayCreator.java:98)
at connector.SystemTrayCreator.create(SystemTrayCreator.java:36)
at connector.Start.main(Start.java:14)
Exception in thread "main" java.lang.IllegalArgumentException: creating TrayIcon iii     null Image
at java.awt.TrayIcon.<init>(TrayIcon.java:168)
at connector.SystemTrayCreator.create(SystemTrayCreator.java:36)
at connector.Start.main(Start.java:14)
Java Result: 1

在以下法典中:

final TrayIcon trayIcon = 
            new TrayIcon(createImage("C:\icon.gif", "Tray icon"));

iii

protected static Image createImage(String path, String description) {
    Image image = null;

    try {
        File f = new File(path);
        image = ImageIO.read(f);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (image == null) {
        Debugger.showMessage("Resource not found: " + path);
        return null;
    } else {
        return (new ImageIcon(image, description)).getImage();
    }
}

我确信,这条道路是正确的。 此外,这些名字也相应。

任何人都知道什么错误?

问题回答

你的法典似乎被罚款。 目前,在理论上,我面临两个可能的问题:

  1. 档案许可问题。 也许把档案放在除驱使物以外的其他地方,并明确检查其许可。 页: 1 它必须退回<条码>true。

  2. 您的<代码>path论点结尾处可能有一些白色空间。 利用<代码>trim(消除这一可能性。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签