Get resource from jar

Viewed 27256

I have jar with files:

myJar/res/endingRule.txt
myJar/wordcalculator/merger/Marge.class

In Marge.java I have code:


private static final String ENDINGS_FILE_NAME = "res/endingRule.txt";
....
InputStream inputStream  = getClass().getClassLoader().getResourceAsStream(ENDINGS_FILE_NAME);
.....

But after this inputStream is null. How to work with resources? Why null?

4 Answers
Related