목록2018/12/12 (1)
낭만 프로그래머
Exception의 Stack Trace를 String으로 변환
import java.io.PrintWriter; import java.io.StringWriter; public class PrintStackTrace { public static void main(String[] args) { try { int division = 0 / 0; } catch (ArithmeticException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); System.out.println(exceptionAsString); } } } 참고 : https://www.programiz.com/java-progra..
Java/Common
2018. 12. 12. 15:00