• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Bear Bibeault
  • paul wheaton
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Mikalai Zaikin
  • Piet Souris
Bartenders:

Deleting a File

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Villains always have antidotes. They're funny that way. Here's an antidote disguised as a tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic