Here you can find the source of getStackTrace(Throwable t)
Parameter | Description |
---|---|
t | the throwable |
public static String getStackTrace(Throwable t)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Firestar Software, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w ww . j a v a 2 s. com * Firestar Software, Inc. - initial API and implementation * * Author: * Gabriel Oancea * *******************************************************************************/ import java.io.*; public class Main { /** * Returns a string representation of the stack trace of a Throwable * * @param t the throwable * @return a string containing the stack trace for the Throwable */ public static String getStackTrace(Throwable t) { StringWriter sw = new StringWriter(1024); PrintWriter pw = null; try { pw = new PrintWriter(sw); t.printStackTrace(pw); pw.close(); } catch (Exception ignored) { } return sw.toString(); } }