Search code examples
javaformattingfilesystemsdisk-partitioning

Is it possible to format a memory stick, pen drive or disk using Java?


I would like to create a multi-plattform utility to format / erase memory sticks, disks, etc.

Is it possible to do this in Java? Or do I need to call native methods for each operational system plattform?


Solution

  • It is very system specific, there is no universal way to perform this. Your options are

    1. Create a JNI library to perform this using system calls
    2. Write a wrapper class around utilities that perform this operation (for example, capture stdout and give inputs to stdin for an external process)
    3. Use OS-specific techniques (as previously mentioned) to zero out devices
    4. Use something like fat32-lib to manipulate specific file system types.