In this example we are writing text into file.In this example we are initialize string to write into file. We are creating file in which we are writing string by use of write() method.
We need java.io.* package import first. The create a .txt file with name "write.txt". We are using FileWriter class to read file for modification. BufferedWriter class is used for buffering the file which will store into an object of Writer class .Then we are using write() method to write text into file. At last close output file using close() method.
The code of the program is given below:
The output of the program is given below:
C:\convert\rajesh\completed>java WriteTextFileExample Your file has been written
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.