I have a file in package '\src\main\resources\'. I want to read that file in a .java file which is located at 'src\main\java\com\xxxx\xxxx\services\'.When I run the following code,
File USER_DIRECTORY = new File( System.getProperty("user.dir") );
File DOCUMENT_DIRECTORY = new File( USER_DIRECTORY, "src/test/resources" );
File template = new File( DOCUMENT_DIRECTORY, "input.docx" );
I am getting value of USER_DIRECTORY as 'C:\workspace\apache-tomcat-7.0.70\bin' and DOCUMENT_DIRECTORY as 'C:\workspace\apache-tomcat-7.0.70\bin\src\test\resources'. The target file is not present in that location. If I run the same code in unit tests, I am getting right values. Can someone help me how to read a file from different package? Please let me know if additional information is required to better understand the issue.