BufferedReader Class with readLine() method

In this blog, we will again work on BufferedReader class with readLine() method. But in this program will control our string in output. Like when we write “stop” word in output screen, program will automatically stop and display final result.

 

Let’s take example on BufferedReader Class

import java.io.*;

class io2

{

                public static void main(String args[]) throws IOException

                {

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

                                String str = “”;

 

                                while((str = br.readLine()).compareTo(“Stop”) !=0)

                                {

                                                System.out.println(str);               

                                }                                             

                }

}

Output:

Welcome in Portal IssSearch Stop

Welcome in Portal IssSearch

 

Video available on YouTube.


[sbscrbr_form]

If you have any query on blog example, you can directly comment us or subscribe our website


Earn Money Online

593total visits,2visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Comments are closed.