Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java accessing Hard disk clusters?  RSS feed

 
S Chan
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I wonder if it is possible for Java to access Hard disk clusters?

Let's say I want to write a file rescue program with Java. Normal deleting operation by OS is to just remove the pointer of the file, so the file is "lost" in the large sea of hard disk clusters. The actual file still exists in the hard disk if it is not overwritten or corrupted later on. If I want to write an application in Java so that the application can scan the hard disk clusters to find the deleted file back, how can I do that?

Similarly, if I want to write the application so that it hard deletes a deleted file, i.e. overwriting data over the deleted file at the exact hard disk clusters, is that possible?

Also another example, when Java creates a large file on the hard disk, can I make sure the file is written on continuous clusters on the hard disk (if space available)?
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do that with Java. Not unless you use native code -- and then you aren't doing it in Java.
 
S Chan
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You can't do that with Java. Not unless you use native code -- and then you aren't doing it in Java.


I see. So I guess Java isn't that low level for hard disk mechanics. Thanks
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't be OS-specific - or for that matter, filesystem-specific - and still be "Write Once, Run Anywhere".
 
S Chan
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That explains!
 
Richard Noneya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Chan wrote:Hi all, I wonder if it is possible for Java to access Hard disk clusters?

Let's say I want to write a file rescue program with Java. Normal deleting operation by OS is to just remove the pointer of the file, so the file is "lost" in the large sea of hard disk clusters. The actual file still exists in the hard disk if it is not overwritten or corrupted later on. If I want to write an application in Java so that the application can scan the hard disk clusters to find the deleted file back, how can I do that?

Similarly, if I want to write the application so that it hard deletes a deleted file, i.e. overwriting data over the deleted file at the exact hard disk clusters, is that possible?

Also another example, when Java creates a large file on the hard disk, can I make sure the file is written on continuous clusters on the hard disk (if space available)?


I guess you could open that file for writing and write raw bits, but i don't think that would guarantee that the new file would be written to the same location on the drive, as the index may just be re-referenced. A few years ago I wrote a program in java that 'zeroed' entire hard drives, only I did it with random bits instead of only zeros, so the zeroing process would not be detected but the information was equally nonsense, and I did it by writing 1 Mb files until the hard drive was full then full delete them at the end, it worked. I thought perhaps that might be helpful to you.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!