Java tutorial
//package com.java2s; public class Main { private static String rebuildMsg(StackTraceElement stackTraceElement, String msg) { StringBuffer sb = new StringBuffer(); sb.append(stackTraceElement.getFileName()); sb.append(" ("); sb.append(stackTraceElement.getLineNumber()); sb.append(") "); sb.append(stackTraceElement.getMethodName()); sb.append(": "); sb.append(msg); return sb.toString(); } }