Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
CommPortIdentifier portId = null;
while (portList.hasMoreElements()) {
portId = portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
//log.debug("Found port: " + portId.getName());
if (portId.getName().equals(port)) {
//log.debug("Using Port: " + portId.getName());
found = true;
break;
}
}
}
它让我与Main崩溃:致命异常。