import javax.comm.*;
import java.util.Enumeration;
public class ListPorts {
public static void main(String args[]) {
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
while (ports.hasMoreElements()) {
CommPortIdentifier port = (CommPortIdentifier) ports.nextElement();
String type;
switch (port.getPortType()) {
case CommPortIdentifier.PORT_PARALLEL:
type = "Parallel";
break;
case CommPortIdentifier.PORT_SERIAL:
type = "Serial";
break;
default:
type = "Unknown";
break;
}
System.out.println(port.getName() + ": " + type);
}
}
}
Log teknis programmer Java
Senin, 04 Mei 2009
List available port in java
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar