Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 603
John John Pichler Avatar asked Nov 21 '10 18:11

John John Pichler


2 Answers

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.
like image 147
disrvptor Avatar answered Sep 19 '22 15:09

disrvptor


Not directly. You will need to invoke a operating system specific program to do the actual work for you.

like image 28
Thorbjørn Ravn Andersen Avatar answered Sep 19 '22 15:09

Thorbjørn Ravn Andersen