Here you can find the source of exceptionToString(Throwable e)
public static String exceptionToString(Throwable e)
//package com.java2s; /******************************************************************************* * (c) Copyright 2017 Hewlett-Packard Development Company, L.P. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Apache License v2.0 which accompany this distribution. * * The Apache License is available at//w w w . ja v a2s.com * http://www.apache.org/licenses/LICENSE-2.0 * *******************************************************************************/ import java.io.*; import java.sql.SQLException; public class Main { public static String exceptionToString(Throwable e) { // Print the stack trace into an in memory string StringWriter writer = new StringWriter(); e.printStackTrace(new java.io.PrintWriter(writer)); // Process the stack trace, remove the FIRST null character return writer.toString().replace("" + (char) 0x00, ""); } public static String toString(SQLException e) { String curr = exceptionToString(e) + "\nstate:" + e.getSQLState(); while ((e = e.getNextException()) != null) curr += "\n\n" + exceptionToString(e) + "\nstate:" + e.getSQLState(); return curr; } }