java - How to delete a file after uploading using Struts 2? -


i able upload file using struts2, want drop specified directory don't know how delete.

here code:

public string execute(){   destpath = "/tmp/listfile";   try{     system.out.println("src file name: " + myfile);     system.out.println("dst file name: " + myfilefilename);                      file destfile  = new file(destpath, myfilefilename);     fileutils.copyfile(myfile, destfile);     filelist = listfiles.listallfiles("/tmp/listfile");       return "listfiles";     }   catch(ioexception e)   {     e.printstacktrace();     return "error";   } } 

if use apache commons io it's one-liner:

fileutils.deletedirectory(dir); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -