Created
February 13, 2024 02:56
-
-
Save bluesid/9a8fb0ef7ad8d0a0979086f592aff3f7 to your computer and use it in GitHub Desktop.
Converting a Stack Trace to a String in Java #printStackTrace #JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.baeldung.com/java-stacktrace-to-string | |
String stacktrace = ExceptionUtils.getStackTrace(e); | |
// commons-lang3 jar 구현체 | |
public static String getStackTrace(Throwable throwable) { | |
StringWriter sw = new StringWriter(); | |
PrintWriter pw = new PrintWriter(sw, true); | |
throwable.printStackTrace(pw); | |
return sw.getBuffer().toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment