java - Access file in jar file? -


i need able access file stored in compiled jar file. have figured out how add file project, how reference in code? how might copy file jar file location on user's hard drive? know there dozens of ways access file (fileinputstream, filereader, ect.), don't know how inside itself.

you use this:

inputstream = this.getclass().getclassloader().getresourceasstream(filefromjarfile);

if foo.txt in root of jar file, you'd use:

inputstream = this.getclass().getclassloader().getresourceasstream("foo.txt");

assumes class in same jar file resource, believe.


Comments

Popular posts from this blog

razor - Is this a bug in WebMatrix PageData? -

iphone - Requiring the presence of a method in an id -

xslt - Is it possible to select a node that just includes a subset of the child nodes? -