java - want to delete temporary files on weblogic programmatically -


hi while uploading file using weblogic server. temporary file of file uploaded getting created on folder e:\wl\user_projects\domains\ams_domain\servers\adminserver\tmp\_wl_user\genesisdenmark\3m840e\public.

if upload test.zip being copied on above location name test.tmp. want delete programmitcally. using struts 1.1.

if has done similar it. please help.

thanks!

it may because of other reason. want programmatically delete? may wrong(please let me know if so) can use regular expression match temporary files. better approach if each time on uploading file take file name, search file having same name , .tmp extension. represent file file object, try programmatically if particular file exist delete file.(in struts should in action class or if using spring/ejb along struts should in business logic.) think you'll need following steps

 1. fetch uploaded file name(as think extension)  2. substring of file name upto last location of . (to     file name without extension)  3. append .tmp in file name  4. check condition if file exists in uploading directory  5. if so, delete file 

some sample code, hope may you:

        //get servers upload directory real path name           filepath = getservletcontext().getrealpath("/")+"xml_upload";           system.out.println("the file path "+filepath);           //create upload folder if not exists            file folder = new file(filepath);            if(!folder.exists())            {             folder.mkdir();            }        multipartrequest m=new multipartrequest(req,filepath);      ff=m.getfile("f");      system.out.println("full path file name:"+ff);      //get file name...      filename=ff.getname();      system.out.println("file name is:"+filename);        //now here have file name without extension , append extension .tmp  // let file represented file object ff .....     if(ff.exists())           {            system.out.println("file exist , going delete.");            ff.delete() ;            } 

for 1 of xml upload application used same, xml data updated , new values displayed , if user want discard updation made xml file on clicking on discard button revert changes , delete uploaded xml file.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -