file io - Issue when trying to use getResourceAsStream in java -
so have 2 lines in code follows:
inputstream = this.getclass().getclassloader().getresourceasstream("resources/config"); bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(is));
and file structure in eclipse follows (image posted):
when try run code, nullpointerexceptions when reaches second line (bufferedreader line). can't life of me figure out why inputstream "is" becoming null. ideas?
when using classloader load stream, path using absolute path (so should not use leading /
in case) , should start root package. in case under src
.
so since resource under package qbooksprintfix/resources
should access like:
getresourceasstream("qbooksprintfix/resources/config")
Comments
Post a Comment