Reputation: 2201
When I am going to connect device through USB port, I want to detect it immediately. I am searching for a Java API, my main target is Linux OS.
Does anyone know an API like that?
Upvotes: 1
Views: 242
Reputation: 2080
would also consider monitoring USB events by DBus interface
there is DBus-Java library here and a similar thread but on python here
Upvotes: 0
Reputation: 5657
You can do something like this:
try {
String command = "lsusb"; // you may add some param if you want
// or use adb for instance
Process child = Runtime.getRuntime().exec(command);
// Get output stream to write from it
OutputStream out = child.getOutputStream();
// TODO parsing lsusb output
out.close();
} catch (IOException e) {
}
Upvotes: 1