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

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -