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.
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 it turns up anything, copy and paste to a text editor, and save to usb stick or send it to yourself via web-based email.
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.
发布评论
评论(3)
有时 Eclipse 会保留对您编辑的文件所做的更改。 并不总是有效,但值得一试:
如果您幸运并且有如果您一直在使用 Eclipse 编辑该文件,您应该会在其中找到一些条目。 查找它们,您很可能会找到内容。
这帮助了我无数次,也多次救了我的命。 然而,每次我诉诸它时,我总是感觉像用棒球棒敲我的头,因为我没有尽早对源代码控制系统进行更改。
祝你好运,如果这不起作用,我担心 SO 不会对你有太大帮助:-(
--- 编辑 ---
一些小东西可以帮助让这个技巧变得更有用一点。
您可以更改 Eclipse 在本地历史记录中保留的信息量,转到您的首选项,然后常规 -> 工作区 -> 本地历史记录(此处为 Indigo,在其他版本上可能有所不同)。 如果您容易头晕或熬夜太多,这将帮助您在第二天修复您坚持在睡觉前完成的错误修复。
Sometimes Eclipse keeps the changes it made to the files you edit. Does not always work but it's worth a try :
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.
如果您知道文件中的某些短语或不常见单词,则可以在硬盘驱动器的原始扇区中搜索文本片段。 这将在可能写入的任何地方显示文本:作为分页虚拟内存、作为仍然存在的文件(临时文件或保存的文件)、或者作为已删除且空间尚未重写的临时或保存的文件。
但这会很慢。 如果该文件从未写入磁盘,则不会产生任何结果。 它产生的结果可能是支离破碎的或不完整的。
启动 Knoppix CD 并开始 grep! Knoppix 是一个从 CD 运行的 Linux 安装,无需写入硬盘。
获取 knoppix: http ://www.kernel.org/pub/dist/knoppix/KNOPPIX_V6.0.1CD-2009-02-08-EN.iso)
启动它。 启动一个终端。 搜索硬盘:
如果发现任何内容,复制并粘贴到文本编辑器,然后保存到 U 盘或通过基于网络的电子邮件发送给自己。
如果您有 SCSI 或 SATA 磁盘,则需要使用
/dev/sda
而不是/dev/hda
另一个答案是正确的,操作系统继续运行的每一刻都会降低您的性能。恢复机会。 拔掉电源并使用另一台计算机来准备 knoppix CD。
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.
get knoppix: http://www.kernel.org/pub/dist/knoppix/KNOPPIX_V6.0.1CD-2009-02-08-EN.iso)
Boot it. Start a terminal. Search the hard drive:
If it turns up anything, copy and paste to a text editor, and save to usb stick or send it to yourself via web-based email.
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.
首先,关闭计算机。 此时它打开并使用的每一秒都会减少您恢复文件的机会。
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.