Sunday, May 13, 2012

Read or input form user in Java using BufferedReader

 BufferedReader use to read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.The buffer size may be specified, or the default size may be used. The default is large enough for most purposes.
In Java  BufferedReader is a efficient method to read an input. Here given a short example to read a string from user and print it:



package palindrome;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class  inputExample  {

    public static void main(String[] args) throws Exception {

   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = new String();
 
    s =br.readLine();
    System.out.println(s);
    }
}


11 comments em “Read or input form user in Java using BufferedReader”

Post a Comment

Give your valuable Comment...

 

Programming, Data Structures & Algorithms Copyright © 2011 -- Template created by JAK -- Powered by Blogger