Put both java file and Myfile.txt file in same folder.
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
public class WriteFile {
public static FileWriter writer;
public static BufferedWriter bw;
public static void main(String[] args) {
try{
writer = new FileWriter("MyFile.txt",true);
// writer = new FileWriter("src\\MyFile.txt"); For every time new file.
bw = new BufferedWriter(writer);
bw.write("\n");
bw.write("WRITTING some thing");
bw.close();
System.out.println("Check your file");
}catch(FileNotFoundException e){ e.printStackTrace(); }
catch(IOException e){ e.printStackTrace(); }
}
}
Saturday, May 23, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please put your feedback or your any question related to this blog. Thanks.