CommPortIdentifier.PORT_SERIAL : CommPortIdentifier « javax.comm « Java by API






CommPortIdentifier.PORT_SERIAL

import java.util.Enumeration;

import javax.comm.CommPortIdentifier;

public class MainClass {
  public static void main(String[] ap) {
    Enumeration pList = CommPortIdentifier.getPortIdentifiers();
    while (pList.hasMoreElements()) {
      CommPortIdentifier cpi = (CommPortIdentifier) pList.nextElement();
      System.out.print("Port " + cpi.getName() + " ");
      if (cpi.getPortType() == CommPortIdentifier.PORT_SERIAL) {
        System.out.println("is a Serial Port: " + cpi);
      } else if (cpi.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
        System.out.println("is a Parallel Port: " + cpi);
      } else {
        System.out.println("is an Unknown Port: " + cpi);
      }
    }
  }
}

           
       








Related examples in the same category

1.CommPortIdentifier.PORT_PARALLEL
2.CommPortIdentifier: getName()
3.CommPortIdentifier: getPortIdentifiers()
4.CommPortIdentifier: getPortType()