I want to create some files at WEB-INF/upload and
upload is a folder which contains some upload files.
ServletContext context = getServletContext();
String dir = context.getRealPath("WEN-INF/upload");
File folder = new File(dir);
if(folder.exists()){
//do something
}else{
folder.mkdir();
}
it’s a piece of simple code, and dir like this:
C:\Code\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MON\WEN-INF\upload
So I debug it in eclipse, and at the same time I get into
C:\Code\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MON\WEN-INF\
to watch whether the upload folder is been created.
There’s no any exception, but the folder cannot be created, I don’t know why,
Thanks.
mkdir()doesn’t throw an exception; it returnsbooleanto indicate success or failure. You should always check its return value so your code can react accordingly.As to why it’s not being created, why are you using
"WEN-INF"rather than"WEB-INF"? Is this just a problem of a simple typo?