在Java中使用printStackTrace()方法是什么? [英] What is the use of printStackTrace() method in Java?

查看:408
本文介绍了在Java中使用printStackTrace()方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过一个套接字程序。在其中,<块code> printStackTrace 在catch块的 IOException 对象上调用。

什么

  catch(IOException ioe)
{
ioe.printStackTrace();
}

我不知道其目的。它是干什么用的?

解决方案

异常的堆栈跟踪打印到 System.err



这是一个非常简单但非常有用的诊断异常的工具。它告诉你发生了什么,代码中发生了什么。


I am going through a socket program. In it, printStackTrace is called on the IOException object in the catch block.
What does printStackTrace() actually do?

catch(IOException ioe)
{
    ioe.printStackTrace();
}

I am unaware of its purpose. What is it used for?

解决方案

It prints the stack trace of the Exception to System.err.

It's a very simple, but very useful tool for diagnosing an Exception. It tells you what happened and where in the code this happened.

这篇关于在Java中使用printStackTrace()方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆