import java.util.*;
import javax.comm.*;
import java.io.*;
public class Porty {
static CommPortIdentifier portId,tym;
static Enumeration portList;
private InputStream cos;
private SerialPort porty;
public Porty(){
CommPortIdentifier portID = null;
for (Enumeration portList = CommPortIdentifier.getPortIdentifiers();
portList.hasMoreElements()

{
CommPortIdentifier portId = (CommPortIdentifier)portList.nextElement();
if (portId.getName().equals("COM8:")) {
tym = portId;
}
}
if (tym == null) {
// Unable to find COM8
System.out.println("No Com8");
return;
}
else {
// found COM8
System.out.println("Yes!!! Com8");
}
try{
cos = porty.getInputStream(); //Tu wywala wyjatek:NullPointerException
}catch (IOException e){}
System.out.println("Data from Com8");
System.out.println(cos);
}
public static void main(String[] args){
Porty porcik = new Porty();
}
}
Moze ktos ma jakis inny przykladowy progra ktory potrafi odczytac z portu. Albo wie co jest zle z tym...
[Dodano: 2005-06-04 22:58:49]
OK!! Juz wszystko dziala elegancko !!! Port sie otwiera i dane ladnie sie odczytuja !!!
Dzieki RMK !!


