|
-
Sep 24th, 2007, 01:04 AM
#1
Thread Starter
Hyperactive Member
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.
-
Sep 24th, 2007, 08:03 AM
#2
Re: Taking Input Stream
use the java.util.Scanner class
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|