Here you can find the source of printException(Exception e)
public static void printException(Exception e)
//package com.java2s; //License from project: Open Source License public class Main { public static void printException(Exception e) { StackTraceElement ste = null; // this loop is important to find the proper stack trace element // without this, there may be null fileName and -1 lineNumber int i = 0; while (i < e.getStackTrace().length && (ste = e.getStackTrace()[i++]).getLineNumber() == -1) ;/*from w w w .ja v a 2 s . com*/ if (ste == null) { printError("Utilities.printException error: StackTraceElement ste is null"); return; } // set the respective variables String className = ste.getClassName(); String methodName = ste.getMethodName(); String fileName = ste.getFileName(); int lineNumber = ste.getLineNumber(); // print error message and location printError(e.toString()); printError("\tat " + className + "." + methodName + "(" + fileName + ":" + lineNumber + ")"); } public static void printError(String message) { System.err.println(message); } }