Enumeration portList=CommPortIdentifier.getPortIdentifiers();
CommPortIdentifier cpi;
while( portList.hasMoreElements() ) {
cpi=(CommPortIdentifier)portList.nextElement();
System.out.println( cpi.getName() );
}
output :
COM1
LPT1
LPT2
COM1
LPT1
LPT2
----------------------------------------------
in line : PortList=CommPortIdentifier.getPortIdentifiers();
ports "COM1" "LPT1" "LPT2" are listed twise each.
if you debug this part of code and check portlist variable
you will find that it has 6 elements (COM1 , LPT1, LPT2 , COM1 ,LPT1,LPT2) ??????????????????????