cannot read a file from META-INF

后端 未结 2 1498
不知归路
不知归路 2021-01-01 22:15

I have a big issue doing something really stupid. That is to say open a stream to a resource file in my META-INF folder. I am working on a jar tool and on doing this:

<
相关标签:
2条回答
  • 2021-01-01 22:54

    try this path: META-INF/schema.xsd (first / omitted)

    0 讨论(0)
  • 2021-01-01 23:07

    Try removing first slash:

    InputStream schemaIS = this.getClass().getClassLoader().getResourceAsStream("META-INF/schema.xsd");
    

    You need a leading slash if you are calling the getResourceAsStream method on a Class object. On a ClassLoader object, the path is always absolute, and the leading slash is not necessary.

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