Search code examples
javac++java-native-interfacecross-platformusb-flash-drive

How to work programmatically with MBR and sectors of USB flash?


I develop application and write in Java. My application needs access to MBR of USB flash and to content of its sectors. I thought about using JNI: call methods in Java, their implementation is in C++, use only standard C functions, no WinAPI, no Linux API.

And I don't know about possibility of working with such devices in Java without C++.

Tell me please the best way.


Solution

  • If you're on *nix, you can just access /dev/sda directly. You'll probably want to use a FileChannel to read and write at arbitrary offsets. Windows is a different story.