Open sushiljic opened 4 years ago
Not with this library, but on linux you could execute 'lsusb' and see if the VID:PID is listed (the device and/or mount point will not be listed so there's no way to link anything if there are multiple identical pendrives attached.
Do you need to identify the pendrive using the VID and PID specifically? Can't you use the Serial Number instead?
@samuelcampos I need vendor ID and product ID because It can't be changed easily whereas Serial Number can be changed and also It get changed when formatted. It is good library and It would be best if we can retrieve VID and PID too.
@samuelcampos I need vendor ID and product ID because It can't be changed easily whereas Serial Number can be changed and also It get changed when formatted. It is good library and It would be best if we can retrieve VID and PID too.
Indeed. When expecting a specific device, one could make sure to find the mount point of that particular device. Library looks great anyway! :-)
If you already know what USB device that is used one way that is supported is to give the USB device a Volume Name
and inside the code check for device.getDeviceName().equalsIgnoreCase("myVolumeName")
. Also the mount point might not be that important since the device has a method which returns the root directory as a file. That would be device.getRootDirectory()
.
maybe it can help you (only jdk21 with preview):
I need to use verify the pendrive by its vendor ID and Product ID for its uniqueness so is there way to get VID and PID?