Java Throwable to String stackTrace(Throwable throwable)

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

Description

Write the given stack trace into a String remove the ats in an attempt to not cause Jenkins problems.

License

Educational Community License

Parameter

Parameter Description
throwable whose stack trace to return

Return

String of the given throwable's stack trace.

Declaration

public static String stackTrace(Throwable throwable) 

Method Source Code

//package com.java2s;
/**//from  ww  w  .  ja v a 2s . c  om
 * Copyright 2005-2014 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

public class Main {
    /**
     * Write the given stack trace into a String remove the ats in an attempt to not cause Jenkins problems.
     * @param throwable whose stack trace to return
     * @return String of the given throwable's stack trace.
     */
    public static String stackTrace(Throwable throwable) {
        StringWriter wrt = new StringWriter();
        PrintWriter pw = new PrintWriter(wrt);
        throwable.printStackTrace(pw);
        pw.flush();
        return wrt.toString();
    }
}

Related

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