private static String format(String message, Object... messageArgs) {
    StringBuilder sb = new StringBuilder(message.length() + 8 * messageArgs.length);
    int templateStart = 0;
    for (Object argument : messageArgs) {
      int placeholderStart = message.indexOf("%s", templateStart);
      if (placeholderStart == -1) {
        break;
      }
      sb.append(message.substring(templateStart, placeholderStart));
      sb.append(argument);
      templateStart = placeholderStart + 2;
    }
    sb.append(message.substring(templateStart));
    return sb.toString();
  }
private static String format ( String message , Object ... messageArgs ) { StringBuilder sb = new StringBuilder ( message . length ( ) + 8 * messageArgs . length ) ; int templateStart = 0 ; for ( Object argument : messageArgs ) { int placeholderStart = message . indexOf ( "%s" , templateStart ) ; if ( placeholderStart == - 1 ) { break ; } sb . append ( message . substring ( templateStart , placeholderStart ) ) ; sb . append ( argument ) ; templateStart = placeholderStart + 2 ; } sb . append ( message . substring ( templateStart ) ) ; return sb . toString ( ) ; }
Returns a formatted string using the specified format string and arguments.

@param message a format string
@param messageArgs arguments referenced by the format specifiers in the format string.
If there are more arguments than format specifiers, the extra arguments are ignored.
The number of arguments is variable and may be zero.
@return a formatted string