just get the names of USB devices attached to a system?

后端 未结 3 1891
广开言路
广开言路 2020-12-19 09:10

Aren\'t there any system calls or OS specific functions that can be called by Java to get just the names of the USB devices attached?

I\'ve seen probably 6-7 questio

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 09:28

    You can use the jUsb API, for Linux.

    Or you could launch the terminal in Linux using the Process class, and run ls -la /dev/disk/by-id/usb-* and catch the stdout to know the results.

    For Windows, you can try this : How to find my USB flash drive's path with PowerShell

    EDIT:

    For Windows, another helpful utility is the devcon.exe.

    For more info, check this.

    EDIT 2: For Mac, you could launch the terminal using the Process class, and run system_profiler SPUSBDataType

提交回复
热议问题