I get a file like this:
String myFile = "D:/dev/workspace/MyProject/WebContent/stats/stats.csv"; File statsFile = new File(myFile);
But I want to have only a relative path like stats/stats.csv . I do not want to write the full path in my code.
In the servlet, I do this:
File statsFile = new File(this.getServletContext().getRealPath("/") + "stats/stats.csv");
But here it is not in the servlet. So what is equivalent in java class?
source share