Exception이 발생하게 되면 Call Stack에 대한 내용을 저장을 해야 디버깅을 할 수 있다..
구글링을 하다보니, Save Exception StackTrace to a String 에서 Exception을 String으로 변환하는 쉬운 예를 보여주고 있네요.
몇개의 예가 있긴 한데, 아래의 코드가 간결하고 좋네요.. ^^
public static String getException(Exception e )
{
StringWriter w = new StringWriter();
e.printStackTrace(new PrintWriter(w));
return w.toString();
}
{
StringWriter w = new StringWriter();
e.printStackTrace(new PrintWriter(w));
return w.toString();
}
'java' 카테고리의 다른 글
| convert nanoseconds to seconds or milliseconds (0) | 2010/01/27 |
|---|---|
| Java vs C# Serialize 비교 또는 C# DataSet을 쓰지 말아야 되는 이유(?) (4) | 2010/01/15 |
| Exception StackTrace to a String (0) | 2009/11/24 |
| addShutdownHook() problem with java.util.Timer instance (0) | 2009/11/24 |
| GMail을 통해서 메일보내기.. (0) | 2009/10/19 |