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
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: June 29, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles