Here you can find the source of getStackTrace(Throwable exception)
Parameter | Description |
---|---|
exception | Exception |
public static String getStackTrace(Throwable exception)
//package com.java2s; /*/*from w w w . j a v a2 s .co m*/ * Copyright 2005-2008 by beck et al. projects GmbH, Munich * Copyright 2009 by Kappich Systemberatung, Aachen * * This file is part of de.bsvrz.sys.funclib.losb. * * de.bsvrz.sys.funclib.losb is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * de.bsvrz.sys.funclib.losb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with de.bsvrz.sys.funclib.losb. If not, see <http://www.gnu.org/licenses/>. * Contact Information: * Kappich Systemberatung * Martin-Luther-Stra?e 14 * 52062 Aachen, Germany * phone: +49 241 4090 436 * mail: <info@kappich.de> */ import java.io.PrintWriter; import java.io.StringWriter; public class Main { /** * Gibt den StackTrace der Exception als String zurueck. * * @param exception Exception * * @return StackTrace der Exception als String */ public static String getStackTrace(Throwable exception) { String result = null; if (exception != null) { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); exception.printStackTrace(printWriter); printWriter.flush(); result = stringWriter.toString(); } return result; } }