Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    /**
     * Get the Stack trace from throwable instance.
     *
     * @param t Exception to be print.
     * @return String formed stack Trace.
     */
    public static String getStack(Throwable t) {
        if (t == null)
            return null;
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        return sw.toString();
    }
}