检测/验证SD卡驱动器 [英] Detecting/Verifying SD Card Drive
问题描述
是否可以检测连接到台式计算机的所有SD卡驱动器?在Windows中,SD卡在外观上与其他设备(例如内置硬盘驱动器或类似设备)不同。有没有办法确定驱动器是否是SD卡驱动器?
Is there a way to detect all SD Card drives connected to a Desktop computer? In Windows, SD Cards are visually distinct from other devices like built-in hard drives or similar. Is there a way to tell if a drive is an SD Card drive or not?
例如,列出所有可用文件系统根目录的Java方法是使用 listRoots()
方法,但是它无法分辨文件系统类型,例如外部,内部,操作系统驱动器还是其他类型。
A Java way of listing all available filesystem roots for example is using the listRoots()
method but it cannot tell the filesystem types such as external, internal, OS drive or whatever.
在纯Java中是否有可能?
Is this even possible in pure Java?
注意:
我不要求检测Android手机SD卡,因为这些是搜索时的结果我的问题。
Note:
I'm not asking to detect the Android phone SD Card since these are the results when searching for my question.
推荐答案
此答案已解决。
示例代码:
USBDeviceDetectorManager manager = new USBDeviceDetectorManager();
List<USBStorageDevice> usbStorageDevices = manager.getRemovableDevices();
for(USBStorageDevice usbStorageDevice : usbStorageDevices)
{
System.out.println(usbStorageDevice.getSystemDisplayName());
System.out.println(usbStorageDevice.getDeviceName());
System.out.println(usbStorageDevice.getRootDirectory());
}
我有我的 SD卡
, NAS
, C:
和 D:
驱动器连接的。打印以下内容:
I have my SD card
, NAS
, C:
and D:
drives connected. The following is printed:
SANDISK (E:)
SANDISK
E:\
如预期的那样,仅返回一个结果,因为 SD卡
将 USB读卡器
插入笔记本电脑中被视为 USB
。
As expected, only one result is returned because the SD card
is treated as USB
due to the USB reader
being plugged into my laptop.
这篇关于检测/验证SD卡驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!