我只是想知道连接到系统的输入设备和输出设备是什么。有没有使用java获取输入/输出设备信息的api?
编辑
独立于任何操作系统。
请提出建议。
最佳答案
要查找连接到系统的 USB 设备,您可以使用 jUSB 。这个article有关于如何使用 api 的更深入的信息。特别是,要查找所有 USB 设备(对文章稍作修改):
Host host = HostFactory.getHost();
// Obtain a list of the USB buses available on the Host.
Bus[] bus = host.getBusses();
// Traverse through all the USB buses.
for (int i = 0; i < bus.length; i++) {
// Access the root hub on the USB bus and obtain the number of USB ports available on the root hub.
Device root = bus[i].getRootHub();
int totalPorts = root.getNumPorts();
// Traverse through all the USB ports available on the
// root hub. It should be mentioned that the numbering
// starts from 1, not 0.
for (int j=1; j<=total_port; j++) {
// Obtain the Device connected to the port.
Device device = root.getChild(j);
if (device != null) {
// USB device available, do something here.
}
}
}
同样,您可以使用 MIDI 系统的 api 来查找连接了哪些 MIDI 设备,请参阅 the java tutorials了解更多信息。
关于java - 如何知道连接到系统的输入设备有哪些,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14293956/