Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static final String formatStackTrace(final StackTraceElement pStackTraceElement) {
        return new StringBuilder().append(pStackTraceElement.getClassName()).append('.')
                .append(pStackTraceElement.getMethodName()).append('(').append(pStackTraceElement.getFileName())
                .append(':').append(pStackTraceElement.getLineNumber()).append(')').toString();
    }

    public static final String formatStackTrace(final StackTraceElement[] pStackTraceElements) {
        final StringBuilder sb = new StringBuilder();
        final int stackTraceElementCount = pStackTraceElements.length;
        for (int i = 0; i < stackTraceElementCount; i++) {
            sb.append(pStackTraceElements[i]);
            if (i < (stackTraceElementCount - 1)) {
                sb.append('\n');
            }
        }
        return sb.toString();
    }
}