मैं अपने कॉम्प्यूटर उपलब्ध बंदरगाहों की सूची प्राप्त करने के लिए बस कुछ कोड चलाता हूं और जब मुझे 3 कॉम पोर्ट मुफ्त होते हैं तो यह मुझे झूठा कर देता है। मैं इस प्रोब को कैसे हल करूं?जावा का उपयोग कर अपने पीसी में उपलब्ध सीरियल पोर्ट की सूची कैसे प्राप्त करें?
मेरे कोड:
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());
}
}
}
आउटपुट: झूठी