Sometimes when writing tests in a maven project we need to read the contents of a resource file. These resource files are located in the src/test/resource folder of the project. One way to do this is (other way):
The getResourceAsStream method returns a InputStream to read the contents of the file with the name fileName in the src/test/resource folder. The slash (‘/’) indicates that fileName is the absolute path, i.e, it will open a file named src/test/resource/fileName. If, instead, we did not specified the slash (‘/’), then the file opened would be src/test/resource/modified_package_name/fileName. Where modified_package_name is the package name of the object this with ‘/’ substituted for ‘.’.
View original post 2 more words