开发者

How to refer to reasources/files in the same jar?

I have a jar file that contains two files in the root

tbs.jar

-parser.dat

-MapScript.txt

I've tried to access them with:

getClass().getResource("parser.dat")

and I also tried:

getClass().getResource("/parser.dat")

but neither works. The class that 开发者_StackOverflowI'm using, the class I call "getClass" on, belongs to a package that lies in the same jar. So how am I supposed to refer to the files in the same jar, should I perhaps try "../parser.dat"? Nothing I try seems to work.


try replacing

getClass().getResource("parser.dat") 

with

getClass().getClassLoader().getResource("parser.dat")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜