Here you can find the source of formatCause(final String message, final Throwable cause, final Object... args)
public static String formatCause(final String message, final Throwable cause, final Object... args)
//package com.java2s; /*//from ww w . j av a 2 s .c om * Copyright 2000-2013 Enonic AS * http://www.enonic.com/license */ import java.text.MessageFormat; public class Main { public static String formatCause(final String message, final Throwable cause, final Object... args) { if (cause == null) { return format(message, args); } else { return formatThrowable(format(message, args), cause); } } public static String format(final String message, final Object... args) { if (args == null || args.length == 0) { return message; } else { return MessageFormat.format(message, args); } } private static String formatThrowable(final String message, final Throwable cause) { if (cause == null) { return message; } final int index = message.indexOf("%t"); if (index >= 0) { final String msg = cause != null ? cause.getMessage() : null; final String text = msg != null ? msg : "null"; final StringBuilder stringBuilder = new StringBuilder(message); stringBuilder.replace(index, index + 2, text); return stringBuilder.toString(); } return message; } }