Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用没有getStackTrace()方法的旧 Java 版本进行开发。有一种printStackTrace方法,但它没有在我想要的地方打印。
getStackTrace()
printStackTrace
有没有办法提取Exception ex(在这种情况下是ex,和一个MXExeption)的全部内容?
Exception ex
转换为字符串数组或其他什么?
也许这有帮助:
StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); String stacktrace = sw.getBuffer().toString();