Get way of the project

Asked

Viewed 454 times

0

I have a project JSF and would like to return the project path in a String. This path has to take the folder webapp as root. How I do ?

1 answer

1


To get the project path, use:

ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); 
String diretorio = ec.getRealPath("/");

This "directory" string will leave you at the root of your project. With this, you just have to manipulate the string to go to the desired directory.

A replace, for example, would do exactly as desired.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.