File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes BufferedReader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "BufferedReader" Watch "BufferedReader" New topic


Ayo Ayo

Joined: Sep 05, 2005
Posts: 3
Hello all,

I am trying to write a program that prompts the user to enter a single character e.g 'Y'. The problem is that when I try to read it using the BufferedReader Object: readLine() method and do some comparism with another char variable, it gives me the wrong result, ie always 'No' No matter the input. Does anybody know of a method used to read in a single character?

My code is as follows;

String InData;
String intData1 = "Y"';
BufferedReader dataString =
new BufferedReader (new InputStreamReader(;
System.out.println("Would you like pin strip (�250.00) Y/N"); InData=dataString.readLine();



If your way is easy, you are definitely on the wrong way
Joanne Neal

Joined: Aug 05, 2005
Posts: 3462
Use String.equals() to compare strings, not ==.

Ayo Ayo

Joined: Sep 05, 2005
Posts: 3
Thanks a lot Joanne Neal.

Ayo Ayo
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
a method used to read in a single character?

Look at the API doc for InputStreamReader read() method.
Don't get me started about those stupid light bulbs.
subject: BufferedReader