How to detect a usb drive in Java

前端 未结 2 1035
眼角桃花
眼角桃花 2021-01-21 05:36

I would like to know how to detect a usb drive. I have already read this post but I am interested in knowing if we can just use java.io.*; to check for the usb driv

2条回答
  •  走了就别回头了
    2021-01-21 05:45

    You could you the File.listRoots() Method.

    There is a Post about that: Post on Stackoverflow on File.listRoots()

    The problem here is that you would need a name or some other info to identify the drive as a USB-Drive. Else you can't tell normal drives and usb-drives appart with this method.

提交回复
热议问题