• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Java accessing Hard disk clusters?

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?
 
Sheriff
Posts: 26963
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 24863
174
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That explains!
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic