Reputation: 474
Ok, so I am trying to retrieve and read a text file that is in a WebContent/resources/ folder in my JSF project and I have no idea how to get the relative path to if from my backing bean... Any Suggestions on how to go about retrieving and reading this file?
Upvotes: 1
Views: 6085
Reputation: 8771
You can read your file with resource functions as described in this answer :
How to reference file resource in a JSF Application
InputStream stream = FacesContext.getCurrentInstance().getExternalContext()
.getResourceAsStream("/foo.xsd");
Upvotes: 0
Reputation: 877
((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext()).getRealPath("/resources/")
will give you the file system path of the resources folder.
Upvotes: 3