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

3

5

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?

Afghan answered 21/11, 2010 at 18:2 Comment(1)
What format do you want to use?Wertheimer
C
4

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.
Catkin answered 21/11, 2010 at 19:8 Comment(2)
+1 for mentioning my fat32-lib ;-)Tabulator
@Tabulator your library looks great but I've not found any help or example on how to use it. Did you write anything about that?Terminus
C
4

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

Cruck answered 21/11, 2010 at 18:6 Comment(0)
C
4

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.
Catkin answered 21/11, 2010 at 19:8 Comment(2)
+1 for mentioning my fat32-lib ;-)Tabulator
@Tabulator your library looks great but I've not found any help or example on how to use it. Did you write anything about that?Terminus
N
2

On unix-like systems, you'd be able (only as root, most likely) to read the disk files /dev/{h,s}d* and write whatever byte sequence you want to them, including byte sequences that represent a, say, ext3 file system.

I don't know of any ext3 libraries in Java, though, so you might have to write it yourself. Or a library for the file format you care about.

This is probably not what you want, though, but you can settle for it :-)

Nit answered 21/11, 2010 at 18:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.