Here you can find the source of formatException(Throwable t)
public static String formatException(Throwable t)
//package com.java2s; /*/*from www .ja va 2s.co m*/ * Copyright (c) 2007-2013, 2015 Eike Stepper (Berlin, Germany) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eike Stepper - initial API and implementation */ import java.io.ByteArrayOutputStream; import java.io.PrintStream; public class Main { /** * @since 2.0 */ public static String formatException(Throwable t) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream s = new PrintStream(baos); t.printStackTrace(s); return baos.toString(); } }