Port Finder : COM Port « Development Class « Java






Port Finder

 

import java.io.*;
import javax.comm.*;
import java.util.*;

public class Main
{    
    public static void main(String[] args)
    {
        Enumeration ports = CommPortIdentifier.getPortIdentifiers();
        
        while(ports.hasMoreElements())
        {
            CommPortIdentifier cpi =
                           (CommPortIdentifier)ports.nextElement();
            System.out.println("Port " + cpi.getName());
        }
    }
}

   
  








Related examples in the same category

1.Querying Available COM Ports
2.Printing a FilePrinting a File
3.List the ports
4.Open a serial port using Java CommunicationsOpen a serial port using Java Communications
5.Subclasses CommPortOpen and adds send/expect handling for dealing with Hayes-type modems
6.Read from a Serial port, notifying when data arrives
7.Choose a port, any port!
8.Read from multiple Serial ports, notifying when data arrives on any
9.Demonstrate the port conflict resolution mechanism
10.Port Reader
11.Port Sniffer
12.Port Writer
13.This program tries to do I/O in each direction using a separate ThreadThis program tries to do I/O in each direction using a separate Thread