Here you can find the source of formatv(String format, Object[] args)
public static String formatv(String format, Object[] args)
//package com.java2s; /******************************************************************************* * Copyright (C) 2006-2013 AITIA International, Inc. * //from w w w. j a v a 2 s . c o m * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ public class Main { private static final java.util.Formatter g_formatter = new java.util.Formatter(); /** Returns a string from a format string and its argument. */ public static String formatv(String format, Object[] args) { if (args == null || args.length == 0) return format; synchronized (g_formatter) { g_formatter.format(format, args); g_formatter.flush(); StringBuilder s = (StringBuilder) (g_formatter.out()); String ans = s.toString(); s.delete(0, s.length()); return ans; } } }