Java Throwable to String formatThrowableForHtml(Throwable t)

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

Description

format Throwable For Html

License

Apache License

Parameter

Parameter Description
t a parameter

Declaration

public static String formatThrowableForHtml(Throwable t) 

Method Source Code


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

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

public class Main {
    /**/*w  ww  .  j  av  a  2s . c  o  m*/
     * 
     * @param t
     * @return
     */
    public static String formatThrowableForHtml(Throwable t) {
        String ex = formatThrowable(t);
        return ex.replaceAll("\n\t", " ");
    }

    public static String formatThrowable(Throwable t) {
        if (t == null)
            return "";
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        t.printStackTrace(pw);
        pw.flush();
        sw.flush();
        return sw.toString();
    }
}

Related

  1. formatException(Throwable e)
  2. formatException(Throwable t)
  3. formatException(Throwable t)
  4. formatExceptionForDisplay(Exception e)
  5. formatThrown(final Throwable thrown)
  6. getDetails(Throwable t)
  7. getErrorInfo(Throwable error)
  8. getErrorMessage(Throwable e)