Read a file within a jar from java code present in same jar

后端 未结 1 1105
太阳男子
太阳男子 2020-12-21 13:51

I am trying to read a xsd file kept in a jar using java code kept inside the same jar. I am using the following code.

URL tmpurl = ClassLoader.getSystemResou         


        
相关标签:
1条回答
  • 2020-12-21 14:05

    Hava you tried?

    getClass().getClassLoader().getResource()
    

    Also your classpath in manifest file in jar does matter.

    Please, take a look at accepted answers in here:

    Class.getResource and ClassLoader.getSystemResource: is there a reason to prefer one to another?

    Loading files with ClassLoader

    0 讨论(0)
提交回复
热议问题