50,523
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args)
{
try
{
Host host = HostFactory.getHost();
Bus[] bus = host.getBusses();
int total_bus = bus.length;
for (int i=0; i<total_bus; i++)
{
Device root = bus[i].getRootHub();
int total_port = root.getNumPorts();
for (int j=1; j<=total_port; j++)
{
Device device = root.getChild(j);
if (device != null)
{
// 操作USB
}
}
}
} catch (Exception e)
{
System.out.println(e.getMessage());
}
}