
{filelink=28}
import javax.comm.*;
import java.util.*;
public class ID_Port {
public static void main(String[] args)
{
Enumeration listePorts = CommPortIdentifier.getPortIdentifiers();
while (listePorts.hasMoreElements()) {
CommPortIdentifier com = (CommPortIdentifier) listePorts.nextElement();
System.out.print(com.getName());
switch(com.getPortType())
{
case CommPortIdentifier.PORT_PARALLEL:
System.out.print(", Port parallèle, ");
break;
case CommPortIdentifier.PORT_SERIAL:
System.out.print(", Port Série, ");
break;
default:
// Autre Port, USB par exemple
System.out.print(" ,Port inconnu, ");
break;
}
}
}
}