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

422total visits,6visits today


mayank

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

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.

Website

Link back if you want.

Enter Captcha Here :*

Reload Image