// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.*;

public class Fmt {
    public static void main(String[] args) throws IOException {
        int v = 123;
        System.out.printf("%05d\n", v);
        System.out.printf("%05dxyz%s\n", v, ".");
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        pw.printf("%05dxyz%s", v,".");
        pw.close();
        String s = sw.toString();
        System.out.println(s);
        PrintWriter pwf = new PrintWriter(new FileWriter("C:\\z.txt"));
        pwf.printf("%05dxyz%s", v,".");
        pwf.close();
        String sf = String.format("%05dxyz%s", v,".");
        System.out.println(sf);
    }
}
