Source code: com/chaoswg/util/ExceptionPrinter.java
1 //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/util/ExceptionPrinter.java,v 1.1.1.1 2003/08/07 13:40:26 toggm Exp $
2 /******************************************************************************
3 * CHAOSWG.COM
4 * -------------------------------------------------------------------------- *
5 * URL: http://www.chaoswg.com/ *
6 * Author: Mike Toggweiler (2.dog@gmx.ch) *
7 * *
8 * Last Updated: $Date: 2003/08/07 13:40:26 $, by $Author: toggm $ *
9 * Version: $Revision: 1.1.1.1 $ *
10 * -------------------------------------------------------------------------- *
11 * COPYRIGHT: (c) 2003 by Mike Toggweiler *
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 *****************************************************************************/
18
19 package com.chaoswg.util;
20
21 //third company code imports
22 import java.io.*;
23
24
25 /**
26 * This is a helper class and defines static methods for exeption
27 * printing
28 * @author Mike Toggweiler
29 **/
30 public class ExceptionPrinter {
31 /**
32 * Creates a String of a throwables stacktrace
33 * @param throwable Trowable who's stacktrace to print
34 * @return string of stacktrace
35 **/
36 public static String getStackTrace(Throwable throwable) {
37 //StackTraceElement[] ste = throwable.getStackTrace();
38 //String st = "";
39 //for(int i = 0; i < ste.length; i++) {
40 // String stes = ste[i].toString();
41 // st = st.concat("\n"+stes);
42 //}
43 ByteArrayOutputStream out = new ByteArrayOutputStream();
44 throwable.printStackTrace(new PrintStream(out));
45
46 return out.toString();
47 }
48 }