问题描述
我想知道如何检测一个USB驱动器。我已阅读,但我感兴趣知道我们是否可以使用 java.io。*;
来检查USB驱动器。我已经阅读的文章,有解释如何使用 java.io。*;
但我不太明白。如果有人能提供一个例子,那就太棒了。谢谢。您可以使用File.listRoots()方法。
有一篇关于这个的文章:) p>
这里的问题在于,您需要一个名称或其他信息来将驱动器标识为USB驱动器。否则,你不能用这种方法告诉正常的驱动器和USB驱动器。
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 drive. The post that i have read up, does kind of explain how to use java.io.*;
but I didn't quite understand. If someone could provide an example, that would be great. Thank you.
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.
这篇关于如何检测Java中的USB驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!