Vim*_*deo 7 java serial-port javax.comm
我只是运行一些代码来获取我的cmputer的可用端口列表,当我有3个免费的COM端口时,它返回了我的错误.我该如何解决这个问题?
我的代码:
public static void main(String[] args) {
//SerialParameters params=new SerialParameters();
// System.out.println(CommPortIdentifier.PORT_SERIAL );
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
System.out.println(portList.hasMoreElements());
while(portList.hasMoreElements()){
System.out.println("Has more elements");
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
System.out.println(portId.getName());
}
else{
System.out.println(portId.getName());
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出:false
归档时间: |
|
查看次数: |
16805 次 |
最近记录: |