Include filename/line number corresponding to System.out.print statements in Eclipse Console

前端 未结 3 2055
星月不相逢
星月不相逢 2020-12-16 06:05

Is there a way to show line numbers in the Eclipse console?

My intent here is to show in the Eclipse console the file/line number that produced the output, not a se

3条回答
  •  别那么骄傲
    2020-12-16 06:55

    You need to add line output to the exception handler.

    For example:

    ...
            } catch (Exception e) {
                System.out.println(e.getStackTrace()[0].getLineNumber());
            }
    ...
    

    This code will print out the line that caused the exception.

提交回复
热议问题