Forums Register Login

Sometime not deleting files

+Pie Number of slices to send: Send
Hello,

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



Best regards
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
This is the main problem that I am not having any exception or error message.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
On a side note, the null check on line 7 is unnecessary as you just created the File object.
+Pie Number of slices to send: Send
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
You guys haven't done this much, have ya? I suggest you study this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 755 times.
Similar Threads
Unable to delete file
How to copy PDF/Ms Word file to another directory
java.io.FileNotFoundException
Using FTP in jsp
files are not delete
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:03:47.