public static Device[] listDevicesBySerialNumber(String serialNumber)
throws FTD2xxException {
List<Device> devices = new ArrayList<Device>();
for (Device d : listDevices()) {
if (d.getDeviceDescriptor().getSerialNumber() == serialNumber) {
devices.add(d);
}
}
return devices.toArray(new Device[devices.size()]);
}
The comparison if (d.getDeviceDescriptor().getSerialNumber() == serialNumber) must be changed to if (d.getDeviceDescriptor().getSerialNumber().equals( serialNumber) ).
== makes reference comparison (pointing to same object) while .equals() makes string comparison. (strncmp)
reference comparison does only work if the string for the method comes from within the class and is static final. In this case we want to use e.g. listDevicesBySerialNumber( "myserial123" ) which doesn't work.