We would like to know how to create PrintWriter from File name.
// w w w .j a va 2 s . c om import java.io.IOException; import java.io.PrintWriter; public class MainClass { public static void main(String[] args) { try { PrintWriter pw = new PrintWriter("c:\\temp\\printWriterOutput.txt"); pw.println("PrintWriter is easy to use."); pw.println(1234); pw.close(); } catch (IOException e) { } } }
The code above generates the following result.