How Do I Eject a Volume in Java?

前端 未结 2 1594
走了就别回头了
走了就别回头了 2021-01-06 10:45

How can I \"eject\" a volume with Java, cross platform?

I have a program that does some operations on a removable drive (USB memory card reader), and once it\'s done

2条回答
  •  不思量自难忘°
    2021-01-06 11:05

    Probably isn't the answer you're looking for, but...

    No.

    To my knowledge, there isn't an established single-platform way of doing this. For that matter, I've never come across a Java way of doing this. A rather scary C# CodeProject does allow ejecting devices, but only on Windows.

    The various, depressingly poor, Java USB libraries don't even hint at ejecting devices. They don't work across all platforms, so even if they did it wouldn't help you.

    My suggestion: gin up some scripts or executables for each platform, and then just spin up a Process as needed.

提交回复
热议问题