Here is a Java Program to Read String from Using the BufferedReader
Output of Above Java Program
Enter lines of text.
Enter 'stop' to quit.
Java Programming Language Tutorial
Java Programming Language Tutorial
stop
stop
import java.io.*; class BRReadLines { public static void main(String args[]) throws IOException { // create a BufferedReader using System.in BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str; System.out.println("Enter lines of text."); System.out.println("Enter 'stop' to quit."); do { str = br.readLine(); System.out.println(str); } while(!str.equals("stop")); } }
Output of Above Java Program
Enter lines of text.
Enter 'stop' to quit.
Java Programming Language Tutorial
Java Programming Language Tutorial
stop
stop