• Post Reply Bookmark Topic Watch Topic
  • New Topic

"java.io.IOException: The handle is invalid" in Win 2000

Eric Knapp
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in instructor at a community college and I have many students who can't get something to work under Windows 2000 with
jdk1.3. They are trying to perform a simple System.in.read() and they get this:
java.io.IOException: The handle is invalid
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:183)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:186)
at java.io.BufferedInputStream.read(BufferedInputStream.java:204)
at Demo.main(Demo.java:8)
Exception in thread "main"
I can't reproduce this on my Linux box and the students in the class who are running Windows 98 also are not having any problems.
Can anyone help?
John Dale
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for grins, I tried to reproduce on Windows NT4 workstation SP6a, with
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
I tried witih input from console, redirect from text file, and pipe from text file. All worked. However, I see something I didn't expect for input from the console, which may be evidence of a problem in the Java library that might lead to system-dependent results.
Windows NT 4, as have its ancestors back to at least CP/M, treats a line beginning with control-Z as an end of file indication. And as expected, when reading from System.in, typing
causes System.in.read() to return -1. However, if you issue another System.in.read(), it blocks instead of returning -1 immediately (which is what it returns when reading from a file or pipe). So the Java library seems to be asking the OS for another octet even though it is already recognized the end of file. If you now type <letter><Enter>, read() returns the code for the letter you typed, instead of -1.
This suggests to me that the Java reading from the console after it has already indicated EOF. Perhaps the results of this is different for Win2000 than for NT4 or Win98.
In case it is of interest, here is my test program. Can anyone see a flaw in my obsevation?
import java.io.IOException;
class SystemInReadTest {
public static void main(String[] args) throws IOException {
while (System.in.read() != -1)
{ }
System.out.println("Got EOF, reading again gives...");
[This message has been edited by John Dale (edited May 06, 2001).]
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently you need to install the service pack 1 (sp1) to fix a few problems in win2000.
This has a link to the download. http://support.microsoft.com/support/kb/articles/Q273/7/35.ASP
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!