Question

I am making a Java Desktop Application that is going to "Shred" or "Swipe" or "More Permanently Delete Diles". I can do the swiping but first I have to find and access the deleted files.

Is there some tool or utility that I can use to access deleted files? I could restore them to a temporary location and then shred them. Or is there a way I can do this with Java or the command line?

Was it helpful?

Solution

How do I list files marked as deleted by the Windows delete process using Java or the Command Line?

The short answer is that you can't do it in Java.

The longer answer is that the only way that you could do this in Java would be write a lot of native code to:

  • access the disk at the disk-block level,
  • decode the file system data structured to locate deleted files and orphaned blocks that were once part of deleted files, and
  • zero the relevant blocks.

... while ...

  • making sure that the blocks haven't been reallocated to another (non-deleted) file, and
  • taking account of other running processes that may be creating, modifying and deleting files.

Doing all of this is really hard if you are implementing everything in C / C++, and even harder if you are doing it from Java. And if you screw it up, you could trash the PC's file system.


A better idea would be to find some existing tool / utility that does the job and use Runtime.exec(...) or equivalent to run it as a separate process.

(I'll leave it to someone else to suggest possible tools / utilities. The sysinternals sdelete tool doesn't appear to deal with files that have already been deleted.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top