 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can store contents in a file using Buffer, Writer in Java. 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 Techimus 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. In this demonstration, I have imported four classes, File, File, Writer, Buffer, Writer and Scanner. Three classes are available in IOPACS and fourth one is available in UTELPACS. Name of this user-defined class is FileWrite which is having main method. Inside main method, all the statements are written in tri-blog so that if any exception will be raised, that will be handled by the catch-plug. Then File class object obj file is created which is linked with file.txt. Then obj file.exist method is checking whether this file is already available or not. So if file is not available, then this if condition will be true and control will be transferred to secondif. Secondif is having a condition obj file.createNewFile. So it will create a new file and this message will be printed file created successfully. If file is created successfully, if not, then control will be transferred to this else which will print file creation failed. But if file is already available, then this firstif condition will be false and control will be transferred to these remaining statements. Here string variable text is declared. Then scanner object sc is created. Then system.out.println is printing enter text to write into file. It will be displayed on console. Then sc.nextline. Nextline method will read the content from the console and those content will be stored inside this text variable. Then an object of file writer class is created that is obj file writer. It is having an argument obj file.getAbsoluteFile. So this getAbsoluteFile method will return name of the file which is linked with this obj file object which we have created here that is file.txt. So this file writer is having name of file where we have to write the contents. Then buffered writer object objbw is created which is linked with the object of file writer that is obj file writer. So at the end we have to use objbw object for writing the content into the file which is used here objbw.write. So the content which is available inside text variable will be written inside file using this write method and after successful writing operation this objbw is closed. Then file saved message will be displayed on console. Here try block is closed. If any exception will be raised that will be handled by this catch block. It is printing all the messages with the help of two string method. All the error message will be available in this x reference that will be displayed here. So this is the explanation of the code. Now you have to notice that I am using eclipse in that environment. I have created a project that is Sanjay and this project is stored inside the location which is D practice. Here you can see the project is available and right now no txt file is available in this project. Now I am executing this code. You can see that file created successfully message is displayed because file is not already available. This file is available here. It is asking for a text. So I am entering my name Sanjay and I am pressing enter key. You can see that this file is containing this text. If I again execute this code. Now it is only asking for the text. It is not creating a new file because file is already available. Now this time I am entering another text that is Vikas. If I open this file you can see the updated text. So this program is working as overriding mode. It overrides all the contents which are available already in the file and new contents are stored. So friends with the help of this simple example you can read some contents from user and those contents will be stored permanently into a file. Now the stored contents can be used in other Java program or you can use that content in form of hard copy whether your Java code is available or not or you can use that txt file in your mailing system so that it can be used by any other user. So this is the benefit of file handling in Java. I hope you have understood the concept well. If you want to watch more programming related videos you can subscribe my YouTube channel. Thank you for watching this video.