Are you a new to java? If yes, find a software that is written in java. You can find easily by searching online. And extend it for your need.
I heard that java doesn't provide an API that allows you to do direct sector reads and writes to the hard disk. If that is true you should seriously consider using something else. You can access the OS libraries that does this via JNI, or you can access the /dev devices that allow you such access -- but again, it is probably much easier to just use C/C++, which can directly access these libraries.
And there are lots of formats such as FAT, NTFS, EXE3 and so on. Do a through research.
If you are a beginner, choose something easy.