62,623
社区成员
发帖
与我相关
我的任务
分享import java.util.Enumeration;
import javax.comm.CommPortIdentifier;
public class TestCom {
public static void main(String argv[]) {
new TestCom();
}
public TestCom() {
CommPortIdentifier portId;
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
if (ports == null) {
System.out.println("No comm ports found!");
return;
}
// print out all ports
System.out.println("printing all ports...");
while (ports.hasMoreElements()) {
System.out.println(" " + ((CommPortIdentifier) ports.nextElement()).getName());
}
}
}