Hello Everybody today we are discuss about writing on the file by using java codes .........
Now we start with coding
JAVA CODE
Thanks for Reading post and please wait for next post in which we discribe how to more about files .
Join this site to know more about programming..
Before we start writing on files:
.For Writing on the file by java code you must know how to compile java program and little more.For this read our previous posts, click here to see .Now we start with coding
JAVA CODE
import java.io.*;
class write_on_file
{
public static void main (String args[])
{
File f=new File("happy.txt");
FileWriter fw=null;
try
{
fw= new FileWriter(f);
fw.write("***WELCOME TO BufferCode.in***Praveen Kumar***");
}
catch(IOException ex)
{
}
finally
{
try
{
fw.close();
}
catch(IOException exp)
{
}
}
}
}
You can use this code to handle your files using java code there you can use your file name which you wants to handle instead of happy.txt .
File f= new File("happy.txt"); is used to make object of file on which we have to write contents.
FileWriter fw=null; is used to make object of typewriter by which the writing operation have to perform.
fw.write("Anything you want to write"); is used to write on file
These are the code by which you can handle your file....
Ouput:
Thanks for Reading post and please wait for next post in which we discribe how to more about files .
Join this site to know more about programming..
No comments:
Post a Comment