IOException with BufferedReader class

IOException is on run time input output exception handler, when we use* package’s classes that time we have to use IOException for handling error.

BufferedReader is one inbuilt class. BufferedReader class must be in* package so we have to import that package in our program starting.

In this program, we will see how to handle run time error without try/catch block.

Example on IOException


class Exc10


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


                        String username = “” , password = “”;


InputStreamReader ir = new InputStreamReader(;      

                        BufferedReader br = new BufferedReader(ir);


                        System.out.println(“Enter Username : “);

                        username = br.readLine(); // Method -> Return String value

                        System.out.println(“Enter Password : “);

                        password = br.readLine(); // Method -> Return String value


                        System.out.println(“Username  : ” + username);

                        System.out.println(“Password  : ” + password);   




Enter Username: demouser

Enter Password: 123456

Username: demouser

Password: 123456


In this program, you can’t understand throws over try/catch. For that we have to watch this video.


Video available on YouTube now.



If you have query about this blog, you can directly post comment or subscribe on website.

Earn money online

1133total visits,3visits today


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

Related articles

Comments are closed.