BufferedReader Class with read() method

In this blog, we will work on BufferedReader class with read() method.

Different between read() and readLine() method

read() -> return type int | ASCII Code

readLine() -> return type String object

 

This is basic different between both method. In this blog, we will see read() method.

 

Let’s take example on BufferedReader Class with read() method

import java.io.*;

class io3

{

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

                {

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

                                                char ch = (char)br.read();

 

                                                System.out.println(ch);

                                                // Program stop when we press Q

 

                                                do

                                                {

                                                                ch = (char)br.read();

                                                                System.out.print(ch);   

                                                }

                                                while(ch!=’Q’);

                }

}

Output:

Welcome in Portal Isssearch Q

Welcome in Portal Isssearch

 

Video available on YouTube.


 

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


Earn Money Online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

233total visits,1visits today


mayank

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

Related articles

Leave a Reply

EmailEmail
PrintPrint