I've been trying to:
- detect a live mounted usb stick
- read its files.
Using usb4java, I was able to fulfill part 1. However usb4Java returns devices and I don't see how I could access the device's files.
This is the code that allows the detection (You can find the complete example on: HotPlug example)
public int processEvent(Context context, Device device, int event,
Object userData) {
DeviceDescriptor descriptor = new DeviceDescriptor();
int result = LibUsb.getDeviceDescriptor(device, descriptor);
if (result != LibUsb.SUCCESS) {
throw new LibUsbException("Unable to read device descriptor",
result);
}
System.out.format("%s: %04x:%04x%n",
event == LibUsb.HOTPLUG_EVENT_DEVICE_ARRIVED ? "Connected" :
"Disconnected",
descriptor.idVendor(), descriptor.idProduct());
return 0;
}