I did in the following way
String n=request.getRealPath("/JSPFiles");
File j=new File(n);
String jk=j.getParent();
out.print(jk);
Frage
I am sorry,may be this is simple question.
I am finding real Path from my web-content folder in the following way.
String directory= request.getRealPath("/JSPFiles");
I got output like this.
C:\Users\Infratab Bangalore\DesktopSubbuFinal\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ExecutableFileProcess\JSPFiles
I want to find Parent Directory from directory
varibale.
C:\Users\Infratab Bangalore\DesktopSubbuFinal\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ExecutableFileProcess
Thanks.
Lösung
I did in the following way
String n=request.getRealPath("/JSPFiles");
File j=new File(n);
String jk=j.getParent();
out.print(jk);
Andere Tipps
Alternative way by splitting strings
To get ExecutableFileProcess
from that string, or any parent directory for that matter, you can use the split
function from the String
class, and index the array:
String parentDirectory = directory.split("\\\\")[directory.split("\\\\").length-1];