java - jar file not properly finding the files -
i have spent past 3 nights going crazy trying find answer this. have java program , want in jar format , want able read in text , image files.
got image files working fine using this.getclass.getresource("")
method, can not program access text files within .jar, when extract jar, text files there know not simple mistake of text files not being within jar
this tried using, didn't work(it works without jar, within jar)
url lurl = this.getclass().getresource("list.txt"); bufferedreader in3 = new bufferedreader(new filereader(lurl.getfile()));
fixes?
assuming class is
my.package.myclass
the method read file directory /my/package
jar.
you can open resource via:
bufferedreader in3 = new bufferedreader(new inputstreamreader( this.getclass().getresourceasstream("list.txt")));
Comments
Post a Comment