4,564,884 th visitor since 2017.2.1 ( Today : 83 )
Programming
No. 355
Name. swindler
Subject. exception trace를 string 으로 만들기
Main Cate. Java
Sub Cate.
Date. 2007-04-05 20:50
Hit. 4680 (211.181.247.3)
File.
가끔 사람들이 Exception 객체나 Throwable 객체를 다루지 못해 불편한 경우를 자주 본다.

대부분 e.printStackTrace() 정도로 stdout 으로만 보낼줄 알고
웹에서만 잘 찍지 못하는 경우가 태반이다.

여러가지 방법이 있긴 하지만,
그냥 Exception Trace 한것을 string 으로 만들어 주는 함수 하나 제작해 본다.




public static String eStr(Exception e)
{
if(e==null) return null;

StackTraceElement [] list = e.getStackTrace();
StringBuffer sb = new StringBuffer();

sb.append(e.toString());

for(int i=0; i<list.length; i++)
{
sb.append("\n at "+list[i]);

}

return sb.toString();
}

[바로가기 링크] : http://coolx.net/cboard/develop/355



swindler getStackTrace method는 JDK 1.4 이상에서 작동함 2007-05-09
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog