Link to home
Start Free TrialLog in
Avatar of yuen_jk
yuen_jk

asked on

input.readLine()

how to use the above function..
i've included the code belows

import java.io.*;

public class Testing
{

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

      System.out.println("Enter a name");
      String search = input.readLine();
      System.out.println(search);
      }
}


but when run they will show that can't resolve symbol at the "input" word....

how to actually use the method?

ASKER CERTIFIED SOLUTION
Avatar of MogalManic
MogalManic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ralf Klatt
Hi,

MogalManic is right with "BufferedReader" ... but you shouldn' place it on the 1st line of the main function ... I'd suggest doing it that way:

import java.io.*;

public class Testing
{
     static BufferedReader input = new BufferedReader (new InputStreamReader(System.in),1);
     /* the buffer is set to 1 beacuse of a known bug in Windows with JDK 1.1.3. and onwards! */

     public static void main(String args[]) throws java.io.IOException
     {
          System.out.println("Enter a name");
          String search = input.readLine();
          System.out.println(search);
     }
}


Best regards,
Raisor
Hi,

I think that I've added a small but not really unimportant information to this question.

My suggestion would be 75% MogalManic and 25% Raisor ...


Best regards,
Raisor
Raisor,

MogalManic's solution is working just fine... no problems.. at least I had no troubles with it last 5 years :)

Venabili