Java Throwable to String stackToString(Exception e)

Here you can find the source of stackToString(Exception e)

Description

stack To String

License

Open Source License

Declaration

public static String stackToString(Exception e) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static String stackToString(Exception e) {
        try {//w w w. j  a v a  2s .  c  o m
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            return "------\n" + sw.toString() + "------\n";
        } catch (Exception e2) {
            return "bad stackToString";
        }
    }
}

Related

  1. getStackTraceWithoutCause(Throwable throwable)
  2. printStackTrace(Throwable t)
  3. serialize(Throwable t)
  4. serializeStackTrace(Throwable _t)
  5. serializeStackTrace(Throwable th)
  6. stackToString(Throwable e)
  7. stackToString(Throwable e)
  8. stackToString(Throwable e)
  9. stackToString(Throwable t)