File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Sometime not deleting files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Sometime not deleting files" Watch "Sometime not deleting files" New topic
Author

Sometime not deleting files

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Hello,

The following code sometime works and sometime not work. Please advise



Best regards
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Under what circumstances it works, and under what it does not?
Are you getting an exception when it doesn't work, and if it is the case can you post the message you get?


The quieter you are, the more you are able to hear.
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
This is the main problem that I am not having any exception or error message.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Well, none of these methods is throwing an exception (an oversight by my side, too).
You should try using new Files.delete(Path) (the class introduced in JDK 7). If something fails, you will get appropriate exception so you can know what went wrong. Check this tutorial.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  18

On a side note, the null check on line 7 is unnecessary as you just created the File object.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Thanks all for assisting me

The real problem was some where else. I mean I not closed the input and output stream that's why the file was not deleted. I properly closed them and it started to work fine

Thanks again & good night
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sometime not deleting files