Getting File from .jar using .getResource()

感情迁移 提交于 2019-12-02 08:56:39

The file is packed, try

resource.getInputStream() 

or

InputStream streamOfYourImg = this.getClass().getRessourceAsStream("com/package/resources/image.jpeg");

Hope it helps

You don't get a File object to it. Its an entry in a JAR not a File on the Filesystem. You have a few options. Create a File by copying the InputStream to the Filesystem, FInd a way to use the InputStream instead, or always have your JAR expanded.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!