Java Throwable to String stackTrace(Throwable t)

Here you can find the source of stackTrace(Throwable t)

Description

stack Trace

License

Apache License

Declaration

public static final String stackTrace(Throwable t) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayOutputStream;

import java.io.PrintWriter;

public class Main {
    public static final String stackTrace(Throwable t) {
        String s = null;//w w  w.  j  av a2  s  .  com

        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            t.printStackTrace(new PrintWriter(baos, true));
            s = baos.toString();
        } catch (Exception e) {
        }

        return s;
    }
}

Related

  1. stackTrace(Throwable e)
  2. stackTrace(Throwable e)
  3. stackTrace(Throwable e)
  4. stackTrace(Throwable exception)
  5. stackTrace(Throwable t)
  6. stackTrace(Throwable t)
  7. stackTrace(Throwable th)
  8. stackTrace(Throwable th, String pattern)
  9. stackTrace(Throwable throwable)