compile java - error messages

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Marks Nkosi

compile java - error messages

Post by Marks Nkosi »

this is program I am trying to compile
/* Program that requires the user for a 4 character
* password and echoes a character
*/

import java.io.*;
import java.util.*;


public class Password {
public static void main(String[] args)
throws java.io.IOException, java.io.FileNotFoundException {

char p1;
char p2;
char p3;
char p4;

System.out.println("Enter a four character password and press ENTER key ");

p1 = (char) System.in.read();
p2 = (char) System.in.read();
p3 = (char) System.in.read();
p4 = (char) System.in.read();

System.out.println("The password you have entered is : " +
p1 + p2 + p3 + p4);
}
}

This are the messages I get

Enter a four character password and press ENTER key
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 Password.main(Password.java:22)
Exception in thread "main"
Post Reply