Java Message Format formatString(String message, Object... args)

Here you can find the source of formatString(String message, Object... args)

Description

Format the given message with the provided arguments.

License

Open Source License

Parameter

Parameter Description
message the message
args the args

Exception

Parameter Description
IllegalArgumentException the illegal argument exception

Return

the string

Declaration

public static String formatString(String message, Object... args) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *******************************************************************************/

import java.text.MessageFormat;

public class Main {
    /**/*from  w  w  w.java 2s .c  o  m*/
     * Format the given message with the provided arguments.
     *
     * @param message the message
     * @param args the args
     * @return the string
     * @throws IllegalArgumentException the illegal argument exception
     * @see java.text.MessageFormat
     */
    public static String formatString(String message, Object... args) throws IllegalArgumentException {
        if (args == null)
            return message;

        return MessageFormat.format(message, args);
    }
}

Related

  1. formatMessage(String message, Object... args)
  2. formatResource(Object[] info, String require)
  3. formats(String pattern, Object... args)
  4. formatString(ResourceBundle resourceBundle, String key, Object data)
  5. formatString(String format, String arg1)
  6. formatString(String str, String pattern)