java.util.Formatter problem
import java.util.Formatter;
import java.io.PrintStream;
import java.io.File;
import java.io.FileNotFoundException;
class Turtle
{
private String name;
private Formatter f;
public Turtle(String name, Formatter f){
this.name = name;
this.f = f;
}
publicvoid move(int x ,int y){
f.format("%s The Turtle is at (%d,%d)\n", name, x, y);
}
publicstaticvoid main(String[] args)
{
PrintStream outAlias = System.out;
try
{
File file =new File("E:\\test\\temp.txt");
Turtle tommy =new Turtle("Tommy",new Formatter(file));
Turtle terry =new Turtle("Terry",new Formatter(file));
tommy.move(0,0);
terry.move(4,8);
tommy.move(3,4);
terry.move(2,5);
tommy.move(3,3);
terry.move(3,3);
}
catch (FileNotFoundException fnfe)
{
System.out.println("File not found.");
}
}
}
when i went throught the code for the formatter, it said that if a give a file name as an arguement to the constructor then the output is written to the file but i dont see any content in that file.
could anyone suggest whats wrong with this program
Thanks

