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")
精彩评论