-
Taking Input Stream
I have to take Input Stream of string in console
The obstacle is that System.in.read() takes integer value, so if I even convert it like
var1 = System.in.read();
var2=var1.toString();
It will store the ascii value of the first letter converted into integer as a string. Whereas I needed my string to be be stored.
I have tried several methods on it like converting it
var1= System.in.read();
var2=(String)(var1);
and also used System.console().readline(); which takes string but it is throwing nullpointer exception. (I dont know why)
If anyone knows other method please tell it to me so I can take string input.
-
Re: Taking Input Stream
use the java.util.Scanner class