Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 848
Alex Avatar asked Dec 07 '25 05:12

Alex


1 Answers

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.

like image 115
David Ehrmann Avatar answered Dec 08 '25 18:12

David Ehrmann