开发者

How can one read/recover deleted files

I need some points on:

How can one read/recover deleted files, in Java code. I've used before for file read&write operations, clases from java.io, such as FileInputStream, FileReader, etc., but that's obviously not going to work

So anyone, som开发者_JS百科e points, theory, maybe a link... there has to be a way!


This is impossible to do in Java (at least without dropping to native level through JNI).

Reason being that the standard Java API is a high level API, and this type of business requires low-level file-access. A deleted file is simply not visible through the interfaces that the java.io API provides.


Be aware that on some OS it is nearly impossible to restore a deleted file.

When you talking about Windows filesystems, then with some JNI code you may access the filesystem and reset the delete flag.

Obviously if it is your program that delete files, you may move them into a bin folder, from which you can restore if needed.

Another option could be to write some service that monitors filesystem activity and may copy files into a bin for later restore. Read about jnotify.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜