Here you can find the source of stackTrace(Throwable throwable)
Parameter | Description |
---|---|
throwable | whose stack trace to return |
public static String stackTrace(Throwable throwable)
//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(); } }