• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to delete directory using Java.

 
pawan chopra
Ranch Hand
Posts: 417
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a jsp page, which send a request for bunch of files to download. I am using spring from the controller I am sending request to a service layer class where I am collecting all the directories /sub-directories and files for download and placing them into a new directory which is placed out side the WEB-INF. But my method is unable to delete those files.



I have tried this code in a sample test class and I was able to delete all the directories. Kindly let me know what can be the issue?

Regards,
Pawan Chopra.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pawan,

But my method is unable to delete those files.


What error you get ?
Couple of things to note
1) Your application should have permission to delete the files and directories.
2) The directory must be empty in order to be deleted. So check for isFile() delete all the files first recursively and then go for directories.
 
pawan chopra
Ranch Hand
Posts: 417
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! It has been resolved actually I forgot to close one io stream , my mistake.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!