code: void printStackTrace(String lineSep, java.io.PrintWriter pw) {
          printText(pw, "msg", "Message:");
          pw.println("   " + getMessage());
          printText(pw, "stackTrace", "Stack trace:");
          if (stackTrace == null) {
              if (currentException != null)
                  serializeCurrentException();
              if (stackTrace == null && previousExceptionObject != null)
                  setStackTrace(previousExceptionObject);
          }
  
          if (stackTrace != null) {
              if (lineSep.equals(lineSeparator)) {
                  pw.println(stackTrace);
              } else {
                  char traceLineSep = lineSep.charAt(0);
                  char currentLineSep = lineSeparator.charAt(0);
                  StringBuffer sb = new StringBuffer(stackTrace);
                  for (int i = 0; i < sb.length(); i++) {
                      if (sb.charAt(i) == traceLineSep) {
                          sb.setCharAt(i, currentLineSep);
                      }
                  }
                  pw.println(stackTrace);
              }
          }
  
          if (previousExceptionInfo != null) {
              printText(pw, "previousException", "Previous exception:");
              previousExceptionInfo.printStackTrace(lineSep, pw);
          }
      }
docs: Print the stack trace to a print writer.
  </p>
  If this exception was thrown from a remote process,
  the stack trace will include the stack from the
  remote process.
  
  @param param java.io.PrintWriter