FileDocCategorySizeDatePackage
PrettyPortLister.javaAPI DocExample1070Wed Feb 15 09:20:08 GMT 2006None

PrettyPortLister

public class PrettyPortLister extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


    Enumeration e = CommPortIdentifier.getPortIdentifiers();
    while (e.hasMoreElements()) {
      CommPortIdentifier com = (CommPortIdentifier) e.nextElement();
      System.out.print(com.getName());

      switch(com.getPortType()) {
        case CommPortIdentifier.PORT_SERIAL:
          System.out.print(", a serial port, ");
          break;
        case CommPortIdentifier.PORT_PARALLEL:
          System.out.print(", a parallel port, ");
          break;
        default:
          // Important since other types of ports like USB
          // and firewire are expected to be added in the future.
          System.out.print(" , a port of unknown type, ");
          break;
      }
      if (com.isCurrentlyOwned()) {
        System.out.println("is currently owned by " 
         + com.getCurrentOwner() + ".");
      }
      else {
        System.out.println("is not currently owned.");
      }
    }