Using e.printStackTrace() in Java

前端 未结 5 522
感情败类
感情败类 2021-02-01 12:31

This is probably a newbie question, but hope you can help me. :) I have something like this:

try
{ 
//try to do something there
}
catch (IOException e)
{
//handl         


        
5条回答
  •  遥遥无期
    2021-02-01 12:48

    e.printStackTrace();

    Is not good practice because it prints in the default ErrorStream, which most of the times is the console!

    NetBeans should be warning you about that. The good practice about it, is logging the message. Follow same reference:

    http://onjava.com/pub/a/onjava/2003/11/19/exceptions.html

    EDIT See first comment bellow to more info.

提交回复
热议问题