how to read string using bufferedreader in java code example

Example 1: declare bufferedreader java

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Example 2: BufferredReader Class

package com.javatpoint;  
import java.io.*;  
public class BufferedReaderExample{    
public static void main(String args[])throws Exception{             
    InputStreamReader r=new InputStreamReader(System.in);    
    BufferedReader br=new BufferedReader(r);            
    System.out.println("Enter your name");    
    String name=br.readLine();    
    System.out.println("Welcome "+name);    
}    
}

Tags:

Java Example