Java Throwable to String getStackTrace (final Throwable e)

Here you can find the source of getStackTrace (final Throwable e)

Description

get Stack Trace

License

Apache License

Declaration

public static String getStackTrace (final Throwable e)
    

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file

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

import java.util.Arrays;

public class Main {
    public static String getStackTrace(final Throwable e) {
        final Writer sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw);

        e.printStackTrace(pw);// www.j a  v  a 2  s .c  o m

        return sw.toString();
    }

    /** Varargs wrapper */
    public static String toString(final Object... objects) {
        return Arrays.toString(objects);
    }
}

Related

  1. getExceptionString(Throwable e)
  2. getExceptionString(Throwable t)
  3. getExceptionString(Throwable throwable)
  4. getExceptionText(Throwable e)
  5. getExceptionTrace(Throwable e)
  6. getStackTrace(@Nonnull final Throwable throwable)
  7. getStackTrace(final Throwable aThrowable)
  8. getStackTrace(final Throwable e)
  9. getStackTrace(final Throwable error)