java PrintWriter pw = null;
try
{
pw = new PrintWriter(new BufferedWriter(new FileWriter("test.txt")));
pw.print("This line overwites file contents!");
}
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.io.FileNotFoundException;
import java.io.IOException
public class SolutionXX {
public static void main(String[] args) throws IOException {
PrintWriter pw = null;
try
{
pw = new PrintWriter(new BufferedWriter(new FileWriter("test.txt")));
pw.print("This line overwites file contents!");
}
catch (FileNotFoundException e) { System.out.println("FNF"); }
catch (IOException e) { System.out.println("IOE"); }
catch (Exception e) { System.out.println("E"); }
finally { if (pw != null) pw.close(); }
}
}