• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Do I completely Empty My DIrectory?

 
Stanley Mungai
Ranch Hand
Posts: 155
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Will Someone please tell me Why this code of mine is deleting some files and leavind some behind while I want the Directory to be completely Emptied!!!

My Code is


Well it is just that I thought it should clear the directory.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are different reasons why files cannot be deleted; for example (on Windows) when some process has the file open, or when the user doesn't have permission to delete the file. If these are files that you read or wrote in your own Java program, make sure that you close the file (or any input / output streams on the file) before you try to delete it.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Your directory might contain other directories in which case you would have to go into those and delete the files there in as well, if at all empty according to you is no files/directories to be present.
 
Stanley Mungai
Ranch Hand
Posts: 155
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mohamed and Jesper,

I have Closed all the inputstreams but there is no positive change.

The situation is am Having text files which are getting converted to Pdf. The pdfs are getting sent to an e-mail adress contained in the text files. The program is then supposed to delete both the pdfs and the text files. All the pdfs are getting deleted and Some of the text files. The question is now that the program is reading from all the text files and sending all the Pdfs, Why isn't it deleting all the text files but choosing which ones to delete and leaving some? I do not have other Directories in the same Directory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic