saeedException 0 Newbie Poster
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) ??????????????????????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.