Here you can find the source of format(String str, Object... arguments)
Parameter | Description |
---|---|
str | The string to format |
arguments | Arguments to use in formatting the string |
public static String format(String str, Object... arguments)
//package com.java2s; /* ************************************************************************* * * TMPotter - Bi-text Aligner/TMX Editor * * Copyright (C) 2015 Hiroshi Miura/*www . ja v a2 s . com*/ * * This file come from OmegaT project * * Copyright (C) 2007 - Zoltan Bartko * 2011 Alex Buloichik * * This file is part of TMPotter. * * TMPotter 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. * * TMPotter 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 TMPotter. If not, see http://www.gnu.org/licenses/. * * *************************************************************************/ import java.text.MessageFormat; public class Main { /** * Formats UI strings. * <p> * Note: This is only a first attempt at putting right what goes wrong in * MessageFormat. Currently it only duplicates single quotes, but it doesn't * even test if the string contains parameters (numbers in curly braces), * and it doesn't allow for string containg already escaped quotes. * * @param str The string to format * @param arguments Arguments to use in formatting the string * @return The formatted string * @author Henry Pijffers (henry.pijffers@saxnot.com) */ public static String format(String str, Object... arguments) { str = str.replaceAll("'", "''"); return MessageFormat.format(str, arguments); } }