Output to .txt file

I've been trying to output a String to a file and this is basically what I have so far:

PrintWriter fnameFile=null;

String fname="John Doe";

try{

fnameFile=new PrintWriter(new FileWriter(new File("fname.txt")));

}//try

catch(Exception e){

System.out.println("ERROR");

}//catch

fnameFile.println(fname);

Any help would be greatly appreciated.

Message was edited by:

Marshall_Lewis

null

[471 byte] By [Marshall_Lewisa] at [2007-11-26 23:55:44]
# 1
use BufferedWriter instead. very easy String writing.Good example: http://www.hostitwise.com/java/java_io.html
TuringPesta at 2007-7-11 15:40:04 > top of Java-index,Java Essentials,Java Programming...
# 2
Okay, thanks. I'll play with it and see if I can get that to work.
Marshall_Lewisa at 2007-7-11 15:40:04 > top of Java-index,Java Essentials,Java Programming...