Java Throwable to String getExceptionString(Throwable t)

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

Description

Returns exception string for class

License

Open Source License

Parameter

Parameter Description
t a parameter

Declaration

public static String getExceptionString(Throwable t) 

Method Source Code

//package com.java2s;
/*//from   www  .j av  a 2s  . c o  m
 * Copyright (c) Fiorano Software Pte. Ltd. and affiliates. All rights reserved. http://www.fiorano.com
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

import java.io.*;

public class Main {
    /**
     * Returns exception string for class
     *
     * @param t
     * @return
     */
    public static String getExceptionString(Throwable t) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);

        t.printStackTrace(pw);
        return sw.toString();
    }
}

Related

  1. getExceptionStack(Throwable e)
  2. getExceptionStackTrace(Throwable ex)
  3. getExceptionStackTrace(Throwable exception)
  4. getExceptionStackTrace(Throwable exception)
  5. getExceptionString(Throwable e)
  6. getExceptionString(Throwable throwable)
  7. getExceptionText(Throwable e)
  8. getExceptionTrace(Throwable e)
  9. getStackTrace (final Throwable e)