aspose file tools*
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""java.io.IOException: The handle is invalid" in Win 2000" Watch ""java.io.IOException: The handle is invalid" in Win 2000" New topic
Author

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

Eric Knapp
Greenhorn

Joined: May 06, 2001
Posts: 4
Hello,
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?
Thanks...
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
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
<ENTER><control-Z><ENTER>
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?
<pre>
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...");
System.out.println(System.in.read());
}
}
</pre>
[This message has been edited by John Dale (edited May 06, 2001).]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "java.io.IOException: The handle is invalid" in Win 2000
 
Similar Threads
Axis 1.1 and Attachments
Sad news
Invalid handle exception
Voice Chat Open Source
"java.io.IOException: The handle is invalid" in Win 2000