Here you can find the source of asFormattedStr(String format, String eol, Object... objects)
public static String asFormattedStr(String format, String eol, Object... objects)
//package com.java2s; //License from project: Apache License import java.util.Arrays; import java.util.Formatter; public class Main { public static String asFormattedStr(String format, String eol, Object... objects) { Formatter f = new Formatter(); String s = f.format(format + "%s", objects, eol).toString(); f.close();/* w ww . ja v a 2 s. co m*/ return s; } public static String asFormattedStr(Formatter f, String format, String eol, Object... objects) { String s = f.format(format + "%s", objects, eol).toString(); return s; } public static String asFormattedStr(String format, Object... objects) throws Exception { Formatter f = new Formatter(); try { String s = f.format(format, objects).toString(); return s; } catch (Exception e) { throw new Exception( "Failed to format the values " + Arrays.toString(objects) + " using format:" + format, e); } finally { f.close(); } } public static String asFormattedStr(Formatter f, String format, Object... objects) { String s = f.format(format, objects).toString(); return s; } }