3

Does anyone knows how to unmount a drive in java in OSx

I am trying to unmount a sdcard from java. I am using java Swing class and the drive gets mounted automatically, but how do I unmount it.

2 Answers2

2

The concept of mounting/unmounting is not platform agnostic, so it doesn't exist directly within the Java APIs. You will most probably have to issue a command line call to unmount by using Runtime.exec()

There might be open source libraries available that wrap this exec call for you, but I'm not positive.

rfeak
  • 8,124
  • 29
  • 28
  • I have a error in Java Swing class while unmounting an SD card. The following works fine with command prompt "umount -f /Volume/ NO \NAME/". Now if I have to write the runtime.exec() by passing the directory path from swing class I can generate the following command, "umount -f /Volume/ NO NAME/". How to work around the problem of space in java – Arindam Bhattacharjee Jan 03 '12 at 22:31
1

You could call umount using Runtime.exec. Of course, this solution is not portable.

Óscar López
  • 232,561
  • 37
  • 312
  • 386