> And what happens if you also use [new FileInputStream("COM10");] for
> reading?
I tried that.

You can't open the same port twice. The following
code:
try {
FileInputStream fis = new FileInputStream("COM10");
FileOutputStream fos = new FileOutputStream("COM10");
} catch (Exception e) {
System.err.println(e);
}
produces the following output:
java.io.FileNotFoundException: COM10 (Access is denied)
In C I can achieve the goal by calling port = open("COM10", O_RDWR);
but I don't know the equivalent in Java.
I guess I'll have to look up another solution to my problem. Anyway,
thanks for trying to help.