e.printStackTrace() 을 String 으로 변환

[언어] JAVA/Java 2015. 2. 20. 14:52
/**
 * e.printStackTrace() 을 String 으로.
 * @param t
 * @return
 */
public static String makeStackTrace(Throwable t) {
if (t == null)
return "";
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
t.printStackTrace(new PrintStream(bout));
bout.flush();
String error = new String(bout.toByteArray());
return error;
} catch (Exception ex) {
return "";
}


'[언어] JAVA > Java' 카테고리의 다른 글

JDK 1.7 Ant FTP전송 에러  (0) 2015.02.20
Templete  (0) 2015.02.20
javax.servlet.jsp.tagext.SimpleTagSupport  (0) 2015.02.20
줄바꿈 처리 CR/LF  (0) 2015.02.20
HttpClient 4.X  (0) 2015.02.20
: