File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Deleting a File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Deleting a File " Watch "Deleting a File " New topic
Author

Deleting a File

Thennam Pandian
Ranch Hand

Joined: Oct 11, 2005
Posts: 163
Dear Friends,

i am trying to delete a file in java . using delete function

in File class. After Deleting the file , the File is not shown in recycle

bin . then , where it is gone?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
I'm just guessing here, but maybe it's been... deleted? As if you've deleted a file and also emptied the trash. It's gone. Java doesn't necessarily know or care how to collaborate with the Windows garbage can. At least it doesn't under Windows 2000 PRo; I don't know about other systems. If you want to be able to recover a file later, don't delete it using Java's File class. You could move it to some other location using renameTo() if you prefer.

It's also possible that some other program like Norton SystemWorks might know how to recover the file if you really need to. However, it's not something supported by the standard Java libraries. Hope that helps...


"I'm not back." - Bill Harding, Twister
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
The "Recycle Bin" is a Windows Explorer concept.
Trying deleting using the 'del' command at the command line - you won't see any Recycle Bins there either.


Tony Morris
Java Q&A (FAQ, Trivia)
Mark Van Tuyl
Ranch Hand

Joined: Mar 22, 2002
Posts: 60
The File.delete() method uses the filesystem of the underlying OS to perform the delete function. If the Windows filesystem had been configured to send deleted files to the Recycle bin, that is what would happen.

Windows Explorer moves files to the recycle bin and the underlying delete function isn't called until the recycle bin is emptied.


<a href="http://www.catb.org/~esr/faqs/smart-questions.html" target="_blank" rel="nofollow">How To Ask Smart Questions</a>
Randhir Yadav
Greenhorn

Joined: May 03, 2006
Posts: 2
File.delete() in java permanently deletes the file instead of moving it to the recylce bin. And this behaviour is independent of the Windows settings to move the files to Recycle bin while deleting it.

But I think Java or may be SWT should provide some options to delete the file to recycle bin or may be this behaviour shoudl be dependent on the OS settings.

--Randhir
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deleting a File