input error I've never before encountered

T

T-Storm

I recently reformatted my HDD, and subsequently reinstalled NetBeans IDE.
Now, none of my Java apps will function properly, because the system returns
the null value for all instances of System.in. For example, the following
method simply prints on the screen, "null". Does anyone know why?

public static void main(String[] args) throws IOException {
BufferedReader test = new BufferedReader(new
InputStreamReader(System.in));
String aLine = test.readLine();
System.out.println(aLine);
}
 
A

Andrew Thompson

Does anyone know why?

I'd guess it has something to do with your IDE or it's
set-up.

You might try consulting
a) the manual/help supplied with it
b) the manufacturer.

( Unless, of course, you cannot run a 'HelloWorld'
example form the command line, in which case it
would more likely be a failed Java installation. )
 
P

Patricia Shanahan

T-Storm said:
I recently reformatted my HDD, and subsequently reinstalled NetBeans IDE.
Now, none of my Java apps will function properly, because the system returns
the null value for all instances of System.in. For example, the following
method simply prints on the screen, "null". Does anyone know why?

public static void main(String[] args) throws IOException {
BufferedReader test = new BufferedReader(new
InputStreamReader(System.in));
String aLine = test.readLine();
System.out.println(aLine);
}

The quoted program will print "null" if its standard input is empty.
test.readLine() returns null for end of file, and println prints a null
string as "null".

Is it possible that something changed to make input files empty?

Patricia
 
?

-

T-Storm said:
I recently reformatted my HDD, and subsequently reinstalled NetBeans IDE.
Now, none of my Java apps will function properly, because the system returns
the null value for all instances of System.in. For example, the following
method simply prints on the screen, "null". Does anyone know why?

public static void main(String[] args) throws IOException {
BufferedReader test = new BufferedReader(new
InputStreamReader(System.in));
String aLine = test.readLine();
System.out.println(aLine);
}
--

Usually, the readLine() has to be in a loop if you want to continuously
read the input:

while ((aLine = test.readLine() != null) {
System.out.println(aLine);
}

and the loop is in another thread.

Most likely your readLine() returns null.
 
T

T-Storm

Patricia Shanahan said:
The quoted program will print "null" if its standard input is empty.
test.readLine() returns null for end of file, and println prints a null
string as "null".

Is it possible that something changed to make input files empty?

I haven't messed around with the BIOS or Windows settings (yet), so the
standard input device SHOULD be the keyboard. I was also under the
impression that a simple System.in call defaulted to the keyboard in Java.

I'm going to attempt the suggestion of putting the readLine() call inside a
conditional loop, and I'll let you know if that solves the problem.
Otherwise, I'll be testing a "Hello, World!" programme from the command line
(another suggestion) and possibly reinstalling the JRE/JDK.
 
T

T-Storm

Ok, I figured out the problem. Java really dislikes the WindowsXP "Language
Bar." Even if set to "English," Windows must be doing something
non-standard, because Java just won't accept anything inputted via the
keyboard. Once I uninstalled the Language Bar, it worked fine.
Unfortunately, since I need to use Korean characters for several
applications, uninstalling it is not an option. :-( Thanks for all the
advice, though. It was much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top