14

I'm using eclipse, when i close eclipse, it ask me save a file, I press yes and eclipse shuts down. When I open my computer I see that the drive only has 3 bytes left, and I get a bad feeling. I go to my file and oh my god, it's totally blank, size is 0 byte! :(

I need that file back, can a free recovery program can work on this case?

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
StoneHeart
  • 15,790
  • 32
  • 67
  • 84
  • how is this programming related? – cbrulak Apr 03 '09 at 04:30
  • 3
    Well, accessory to programming are the tools we use to do it, and sometimes we have to dance circles around them chanting weird incantations to get the programming part done. – Newtopian Apr 03 '09 at 04:56

3 Answers3

41

Sometimes Eclipse keeps the changes it made to the files you edit. Does not always work but it's worth a try :

  • Find you file in your (package, project, navigator) explorer.
  • Right click on your file and look for the menus to compare... (I recommend Compare though in your case it will not matter since the file is now empty)
  • Choose Local History... from the sub menu

If you are lucky and had been using Eclipse to edit the file you should find a few entries there. Look them up, chances are you will find the content.

This has helped me countless times and saved my ass on many occasions. However, every times I resort to it I always feel like hitting my head with a baseball bat for not commiting changes to the source control system earlier.

good luck, if that does not work I fear the SO will not be of much help to you :-(

--- EDIT --- Little something that can help make this trick a tad bit more useful.

you can change the amount of information Eclipse keeps in local history, go to your preferences and then general->Workspace->Local History (Indigo here, may be different on other versions). If you tend to be light headed or burn the midnight oil a bit too much this will help you repair the next day that bug fix you insisted on finishing before going to sleep.

Newtopian
  • 7,543
  • 4
  • 48
  • 71
  • 6
    cookie for u http://thehealthblogger.com/wp-content/uploads/2008/07/cookie.jpg :p, i did your way but it said history not found for this file, after that i did myself text search in .metadata\.plugins\org.eclipse.core.resources\.history and got it now, thankyou thankyou thankyou. – StoneHeart Apr 03 '09 at 04:49
  • glad it all worked out for you ... and thanks for the cookie :-) This is one of the nice things about Eclipse, a lot happen in the background for you which you can use later for other purposes if needed. – Newtopian Apr 03 '09 at 04:54
  • in my case- "Choose Local History... from the sub menu"- this one worked. U saved me from a massive heart-attack. – Avisek Chakraborty Oct 19 '11 at 19:39
  • Same here, eclipse saved a file as i restarted (leaving it empty) - I already gave up hope - but this worked – Katai Jun 18 '12 at 20:11
  • recently switched to VisualStudio to do some C# work... really love C# as a language but boy do I miss this feature ! Already got burned a few times losing some work :-( – Newtopian Jun 19 '12 at 14:24
  • Man, you just made my day ! I removed all my classes by mistake and the local history let me get them back. – jlengrand Oct 25 '12 at 14:20
  • 1
    @jlengrand glad it helped, working with VisualStudio and man do I miss Eclipse ! – Newtopian Oct 25 '12 at 23:14
  • @Newtopian Haha, same here ! I crave for my Linux, its command line and my beloved Eclipse :p. – jlengrand Oct 26 '12 at 06:40
  • @StoneHeart Followed your tip of looking in the folder manually, after getting told I had no local history for the file and I was able to recover several hours of uncommitted work. Thanks a bunch! – ThatOneDude Apr 26 '15 at 07:39
  • This solution saved me some heartbreak. Look in .metadata\.plugins\org.eclipse.core.resources\.history. Your miracle is there. – tksilicon Oct 17 '19 at 11:24
  • I have not used Eclipse in a long time but from memory the location you are referring to is where the information described above is stored. Thus if one effectively turned off the local history then this location would also be empty. That said, it's been a really long time so YMMV. – Newtopian Oct 17 '19 at 11:45
4

If you know some phrase or uncommon word from your file, you can search the raw sectors of the hard drive for pieces of text. This will turn up the text anywhere it might have been written: as paged out virtual memory, as a stil-existant file (temp file or saved file), or as temporary or saved file that was deleted and the space has not yet been rewritten.

But it will be slow. And if the file was never written to disk, it will yield nothing. And what it yields may be fragmented or incomplete.

Boot a Knoppix CD and start grepping! Knoppix is a linux installation that runs from CD, without writing to your hard drive.

If you have SCSI or SATA disks, you need to use /dev/sda instead of /dev/hda

The other answer is correct, every moment that OS continues running decreases your recovery chances. pull the power and use another computer to prepare the knoppix CD.

Joe Koberg
  • 25,416
  • 6
  • 48
  • 54
2

First, turn off the computer. Every second that it is on and being used at this point reduces the chance you'll recover your file.

thedz
  • 5,496
  • 3
  • 25
  • 29