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

922total visits,2visits 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