aboutsummaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/src')
-rw-r--r--common/src/at/gv/egovernment/moa/util/StreamUtils.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/StreamUtils.java b/common/src/at/gv/egovernment/moa/util/StreamUtils.java
index 88db24504..a22f1c2a8 100644
--- a/common/src/at/gv/egovernment/moa/util/StreamUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/StreamUtils.java
@@ -3,6 +3,7 @@ package at.gv.egovernment.moa.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintStream;
/**
* Utility methods for streams.
@@ -112,5 +113,16 @@ public class StreamUtils {
in.close();
return out.toString(encoding);
}
-
+
+ /**
+ * Gets the stack trace of the <code>Throwable</code> passed in as a string.
+ * @param t The <code>Throwable</code>.
+ * @return a String representing the stack trace of the <code>Throwable</code>.
+ */
+ public static String getStackTraceAsString(Throwable t)
+ {
+ ByteArrayOutputStream stackTraceBIS = new ByteArrayOutputStream();
+ t.printStackTrace(new PrintStream(stackTraceBIS));
+ return new String(stackTraceBIS.toByteArray());
+ }
}