To read a string form the Buffered Reader object, use the following version of readLine() method.
String readLine( ) throws IOException
Example:
import java.io.*;
class StringRead
{
public static void main(String args[]) throws IOException
{
BufferedReader brObj = new BufferedReader(new InputStreamReader(System.in));
String strObj;
System.out.println(“Enter lines of string [‘exit to quit’]”);
do
{
strObj = brObj.readLine();
System.out.println(strObj);
} while(!strObj.equals(“exit”));
}
}
Output: