How do I read a resource file from a Java jar file?

后端 未结 9 1593
遥遥无期
遥遥无期 2020-11-22 09:22

I\'m trying to access an XML file within a jar file, from a separate jar that\'s running as a desktop application. I can get the URL to the file I need, but when I pass tha

9条回答
  •  悲哀的现实
    2020-11-22 10:10

    Looks like you want to use java.lang.Class.getResourceAsStream(String), see

    http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String)

提交回复
热议问题