String (String stackTrace, boolean skipFirstLine) { if (stackTrace == null) return null; StringBuilder builder = new StringBuilder(); String[] lines = stackTrace.split("\n"); for (int i = 0; i < lines.length; i++) { String line = lines[i]; if (i == 0 && skipFirstLine) continue;//first line has unique details line = line.replaceAll("<0x.+>\\s", "<merged>"); builder.append(line).append("\n"); } return builder.toString(); }