java - Static method file path -


this question has answer here:

how path of file in same package class?

this doesn't work.

public static void saveallmockdata() throws exception {           inputstream inputstream = getclass().getclassloader().getresourceasstream("mockdata.json");      } 

you can use

inputstream = yourclassname.class.getresourceasstream("mockdata.json""); 

or can specify package path

getclass()     .getresourceasstream("/abc/efg/mockdata.json"); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -