Please note how getResource() argument value looks. Test class getResource() will resolve /sample.txt properly to /target/test-classes/sample.txt.
You might need to get InputStream from file resource which is easy to done with help of sister method getResourceAsStream():
Read full article from How to get file resource from Maven src/test/resources/ folder in JUnit test? — Virtage Devblog — java, eclipse, eclipse rcp, eclipse rap, swt, jface, osgi, ubuntu, sysadmin, linux, derby, javadb, jet
No comments:
Post a Comment