• Post Reply Bookmark Topic Watch Topic
  • New Topic

Direct Hard Drive Access In Java

 
Jeremy Swensen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Is there a way to access a hard drive (or USB device) in Java without having to use the file system. For example, is there a way to open an input stream to a hard drive and a make a direct image copy of that drive?

Linux c programs like dd_rescue do this quite well but who wants to work with c?

Thanks,

J
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't worked with NIO enough to state definitively, but I would think that no, short of using JNI, there is no way to get that low a level access to a device.
Java is an application-level language. It is a poor choice for doing system-level programming. For example, try to write ping in pure Java. Can't do it because Java doesn't support ICMP sockets.
When I was employed doing system-level programming I used C and it is an excellent tool for that purpose. Direct memory access. No extra layers between your code and the operating-system level API's. The code one writes is very close to what gets executed so hand-optimizations are possible (though not always recommended).
Just because you have a hammer (Java) don't assume all your problems are nails (object-oriented applications).
 
Vlado Zajac
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Linux block devices are files so they should be accessible using java.io or java.nio, by something like


I can't try it now (no Linux).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!