开发者

Remove file from Apache using servlet

I'm uploading files using servlet my little code is like this:

ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());

try {
    fileItemsList = servletFileUpload.parseRequest(request);
} catch (FileUploadException ex) {
    Logger.getLogger(iThink.class.getName()).log(Level.SEVERE, null, ex);
}

String optionalFileNa开发者_运维技巧me = "";
FileItem fileItem = null;

Iterator it = fileItemsList.iterator();
...

The file is uploaded to apache directory (\webapps\mysite\uploads\abd.zip). Uploading is working fine but I want to delete it.


Since you already got a list of FileItem objects you can simply iterate over that list and call FileItem#delete on the items. Alternatively use File#delete from Java's standard library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜