 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can read data which is stored inside a file using Java program. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at bottom right corner of this video. You can download my app Takimas that is available on Google Play. You can connect with me by following these details which are available in front of you. Now coming on to the topic here in this code, I have imported two files file and sorry, two classes file and file input stream. These two files are available in IO package. Then read file is the name of class inside that main method is defined. Main method is containing some statements in which first one is file object obj file, which is having name of file that is file one dot txt and all these statements are written inside try block, which is followed by catch block. Now if condition which is checking that obj file which is having file one dot txt is exist or it is available or not. So if file exist already, then this condition will become false. If condition if file is not available, if a file doesn't exist, then this condition will become true. Then file does not exist. Masses will be displayed and system dot exit will terminate execution of the program because if file doesn't exist, then we don't. Sorry, we can't read anything from that file. Then string text variable is declared, then integer variable val is declared, then file input stream object file in is created, which is linked with obj file. Obj file is containing name of file that is file one dot txt. So it means file in object will read the data which is stored inside file one dot txt. Then system dot out dot println it will display content of the file is masses on console. Then this while loop is responsible for reading contents from the file. So file in dot read read is a method which will read content and that content will be stored inside well. And if value of this reading is not equals to minus one, then only this loop will repeat if the input value is equals to minus one. That means file has come to end of file. So this minus one indicates end of file. So if minus one is not available, then this loop will repeat. Otherwise loop will be terminated and the well value will be further converted into character using this type conversion. So we have type cast a well variable value into character format and then system dot out dot print is printing this content on console. After completion of loop new line is printed, then file in is closed after that catch block is defined. So if a drive will be raising any kind of exception, then that will be catch through this catch block inside EX reference. Then EX will be displaying the content with the help of this two string method. So this is the complete explanation of the program, which is reading some text from file and printing it on console. Now I am executing this code before that I am opening that location where this file one dot txt is already available. So right now I am working in this package Sanjay and I am using eclipse for this editing and execution purpose. So this eclipse is having a package at location D drive inside the package folder. You can see that in package folder, sorry practice folder package Sanjay is available. Here you can see that file one is already available and it is containing because as contained. Now I am executing this code. So you can see that content of the file is because it is printing the data which is already stored inside that file on console. It means it is working properly. Now I am deleting that file. This file is deleted right now. Now again I am executing the code. You can see the output file does not exist. So if file is available, then the content which is available in that file will be displayed on console. If file is not available, then an error message will be displayed with the help of this code. So friends, I hope you have understood how you can read content of a file and that then you can display all the contents on console. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.