GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Saturday, December 18, 2010

Java IO - Reading Text From Console

Here's a simple code for reading a line from console:

import java.io.*;

public class Main{

    public static void main(String[] args){

        BufferedReader reader = new BufferedReader(new
                                InputStreamReader(System.in));
        String text;
        System.out.println("Write your description:");
        try{
            text = reader.readLine();
            System.out.println("Your write: "+text);
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

}
Share/Bookmark

No comments:

Post a Comment