java - Finding a file in a root directory of jar exported from Eclipse for JUNIT testing -
in eclipse junit test have several text input files opened by
new bufferedreader(new filereader(inputfilename));.
they placed in root directory of project after exporting project jar these files placed jar root directory.
run junit test linux
java -cp "<my jar>:junit-4.8.2.jar:jaxb-impl.jar" junit.textui.testrunner <test class name>
however, in case getting java.io.filenotfoundexception best way fix problem on linux , @ same time still able run tests eclipse?
use class#getresourceasstream() method load classpath resources:
inputstream = this.getclass().getresourceasstream("myfile.txt");
you can convert reader
interface using inputstreamreader
adapter.
Comments
Post a Comment