如何检测Java中的USB驱动器 [英] How to detect a usb drive in Java

查看:152
本文介绍了如何检测Java中的USB驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何检测一个USB驱动器。我已阅读这篇文章,但我感兴趣知道我们是否可以使用 java.io。*; 来检查USB驱动器。我已经阅读的文章,有解释如何使用 java.io。*; 但我不太明白。如果有人能提供一个例子,那就太棒了。谢谢。

解决方案

您可以使用File.listRoots()方法。



有一篇关于这个的文章:在File.listRoots()上的Stackoverflow() 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驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆