Sign in to follow this  
hisDudeness

Java input

Recommended Posts

I am using JCreator to write a very simply console-based Java program. Whereas System.out.println() is used to write to the ostream (Java's rendition of 'cout'), what can I use to read in from the istream (the equivalent of 'cin')? Basically, I have a String object that I want to read in from user input; then I want to manipulate user-inputted String.
String str;

// Code that allows users to read into variable 'str' from keyboard.

if(str.equals() == "Hello, Java String Input!")
    System.out.println("Unicorn kisses.");

thanks, hisDudeness

Share this post


Link to post
Share on other sites
System.in.read(...)

(some prefer java.io.Scanner)
I use...
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ;

br.readLine();

If you don't have the java docs on your machine, check out: Java Docs

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this