It looks like you try to connect a USB stick to your Windows OS. I suggest, iterating over all USB devices and check, if the "USB class" is a stick (mass storage, class 8) (see here).
Do you mind giving us further details on your project?
Code snippet
This peace of code finds a attached mass storage device. It is not well tested nor commented.
import java.util.List;
import javax.usb.UsbConfiguration;
import javax.usb.UsbDevice;
import javax.usb.UsbHostManager;
import javax.usb.UsbHub;
import javax.usb.UsbInterface;
import javax.usb.UsbServices;
public class USBHighLevel {
public static void main(String[] args) throws Exception {
UsbServices services = UsbHostManager.getUsbServices();
UsbDevice usbDevice = findDevices(services.getRootUsbHub());
System.out.println("Device=" + usbDevice);
}
private static UsbDevice findDevices(UsbHub node) {
for (UsbDevice usbDevice: (List<UsbDevice>) node.getAttachedUsbDevices()) {
if (usbDevice.isUsbHub()) {
UsbDevice tmp = findDevices((UsbHub) usbDevice);
if(tmp != null) {
return tmp;
}
} else {
if(matchesUSBClassType(usbDevice, (byte) 8)) {
return usbDevice;
}
}
}
return null;
}
private static boolean matchesUSBClassType(UsbDevice usbDevice, byte usbClassType) {
boolean matchingType = false;
UsbConfiguration config = usbDevice.getActiveUsbConfiguration();
for (UsbInterface iface: (List<UsbInterface>) config.getUsbInterfaces()) {
System.out.println(iface.getUsbInterfaceDescriptor().bInterfaceClass());
if(iface.getUsbInterfaceDescriptor().bInterfaceClass() == usbClassType) {
matchingType = true;
break;
}
}
return matchingType;
}
}
Useful links
USB4Java HighLevel API
USB4Java LowLevel API
libusb-1.0 Project Homepage
Great Overview on Java.net