How to read a file from a relative path in Jdeveloper ADF?

2.1k views Asked by At

I want to read a file from a relative path in my Jdeveloper Adf project, I have my files in a path like this "\ProjectName\ViewController\public_html\files", my file is an image, so what can I do?, I want to my code to work in any server.

1

There are 1 answers

0
csuazo On BEST ANSWER

I hope my answer will be useful for others,

I have read the file using code like the following,

        ServletContext servletCtx = ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();


        InputStream inputStream = servletCtx.getResourceAsStream("/images/image.png");

The path for my project and resurces is something like this

"\ProjectName\ViewController\public_html\images"

Regards.