Java tutorial
import java.io.File; import java.io.FileNotFoundException; import java.io.UnsupportedEncodingException; import java.util.Formatter; import java.util.Locale; public class Main { public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { Formatter formatter = new Formatter(new File("generated/format.txt"), "ASCII", Locale.getDefault()); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // flush the formatter. Here it does nothing. formatter.flush(); System.out.println("Formatter Flushed."); } }