Home » Java » java – How do we give path of a file inside a package in spring?-Exceptionshub

java – How do we give path of a file inside a package in spring?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I need to access the assets/names.txt inside FilterBackendApplication.java. How do we do that ? The directory structure looks like this.

  • assets/names.txt
  • entity
  • repo
  • FilterBackEndApplication.java
How to&Answers:

create the file object of that file as follows

java.io.File file = new File("assets/names.txt");