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 |
|||||
|
|||||
[Modify] [Delete] | [Reply] [List] |