• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deleting a File

 
Thennam Pandian
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Van Tuyl
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Randhir Yadav
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic