Java.io.IOException: The handle is invalid

I recently had to format my PC after data corruption, and

whe I reinstalled the Java SDK I found that certain programs

would no longer run after compiling. The problems seems to

be something to do with the input/output. I've tried

reinstalling Java without any luck. The error is this:

Is the boat ready for the journey(y for yes, n for not)?java.io.IOException: The handle is invalid

at java.io.FileInputStream.readBytes(Native Method)

at java.io.FileInputStream.read(FileInputStream.java:192)

at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)

at java.io.BufferedInputStream.read(BufferedInputStream.java:201)

at Boat.performCheck(Ships.java:69)

at Ships.main(Ships.java:19)

Exception in thread "main" Exit code: 1

There were errors

And the code that seems to be affected:

void performCheck() throws IOException

{

char check;

System.out.print("Is the boat ready for the journey(y for yes, n for not)?");

check = (char)System.in.read();

System.in.skip(2);

if(check == 'y')

{

seaWorthy = true;

}// close if block

else

{

seaWorthy = false;

}// close else block

}// close performCheck method

I'm learning Java through a course with a deadline of

November, and this problem is really slowing me down.

Can anyone help? The code compiles without errors, it

just won't run.

[1500 byte] By [BenLearningJava] at [2007-9-27 20:35:27]
# 1
Are you running through java Ships or javaw Ships, i.e. command line or windows-based?Chris.
ChrisBoy at 2007-7-7 1:41:39 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Skip the skip method call.

You might try removing (or commenting out, for starters)the line that calls the skip() method. I'm not sure what it's doing since you've already read the input on the previous line and since old skip has been known to cause problems on occasion.

Also noteworthy would be the line numbers in your code, or at least pointing out which line is #69, since your stack trace is pointing to that line as the culprit:

at Boat.performCheck(Ships.java:69)

Hope that helps.

Dave

p.s. I'm in the hunt for Duke Dollars. If you found that reply of any use, feel free to toss me a few.

bendede2 at 2007-7-7 1:41:39 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

Instead of using the command line to compile the code I'm running it through RealJ, a Java development environment, so I can't be sure whether it's java or javaw it uses.

I commented out the skip method, but didn't have any luck. I've also had this problem on similar code that involves any sort of input through java.io. Line 69 is:

check = (char)System.in.read();

Thanks for the advice so far.

BenLearningJava at 2007-7-7 1:41:39 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...