Hi ,
I am using java1.4
I write following code.
Problem is : In the end new file is created , but it is empty nothing is written
in that file . Why ? line1 and line2 should be placed in the file , why it is not happening ?
import java.io.*;
class
Test {
public static void main(
String args[])
{
try {
File f = new File("test12.txt");
if(!f.exists())
f.createNewFile();
FileWriter fw = new FileWriter(f);
PrintWriter pw = new PrintWriter(fw);
pw.println("line1");
pw.println("line2");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}