 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can read contents of a file using buffered reader in Java. Before starting, you can subscribe my YouTube channel by clicking on the left bottom right corner of this video. You can download my app TechMS that is available on Google Play. You can connect with me by following these details which are available in front of you. You can see a code which is written in front of you. It is importing three classes file, file reader and buffered reader. All three classes are available in IOPACS. Then this user defined class name is read file. It is containing main method. Inside main, a try block is available, which is containing some set of instructions. Try and catch is for exception handling if any exception is raised inside try block that will be properly handled by the catch block. Then file object obj file is created, which is having name of file, file.txt. If condition is checking whether this file is already available or not, so if file is already available, then this if condition will become false. If file is not available, then this condition will be true and file does not exist will be displayed. With the help of system.exit, control of program will be terminated. After this, if a variable text is declared of string type, then integer variable val is declared, then file reader object objfr is created, which is having an argument obj file.get absolute file. This get absolute file is a method which will provide name of file. So obj file is having name of file is file.txt. So here get absolute file method will provide file which is the name of file to this objfr. Then buffered reader object objbr is created, which is having an argument objfr. So finally objbr is linked with the file that is a text file from where we have to read, we have to receive the input. Then system.out.println, this content of the file is will be displayed on console. Then while loop is implemented, which is receiving lines from the file using objbr, and the content is assigned into text. If contents are properly read, then that value will not be equal to null. It means this loop is true, and text will be displayed on console. If this read line method can't read anything from the file, that means file is empty. So this condition will become false. So loop will be terminated. Now objbr.close method is called, that object is closed. Then catch block is defined. If any exception is raised in try block, then this catch will catch that exception using ex reference of exception class. And using this ex.to string, all the error messages will be displayed on console. So this code is right now explained by me, which is stored inside the project Sanjay. And this project is available in this Eclipse software. And this project is stored on a path which is d practice. So inside d drive practice folder is available, which is containing the project Sanjay. Here you can see file.txt is already available. And if I open this file, it is containing Sanjay as text. I have closed that file. Now I am executing this code so that you can see this code is reading the content which is available in file.txt. And that content will be displayed on console. So I have executed that code and you can see the output. Content of the file is Sanjay. It is displaying here. So the content which is available in that file is displayed properly. Now again, I am moving to that location. And inside this project, this file is available. I am deleting this file. So right now file.txt is not available here. Again, I am executing this code. You can see that file does not exist. Message is available here. It means file is not available. That's why this if condition is true. And it is printing file does not exist. Message on console. So friends with the help of buffered reader, you can read content of a file and those contents will be further displayed on the console. But remember that the content of file which you want to read from a file that file must be available in your project so that you can read that file properly. Otherwise an error message will be displayed on console. So implement this code at your own so that you can understand the concept well. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.