Java Stacktrace Print printStackTrace(PrintWriter writer, Thread thread, StackTraceElement[] trace)

Here you can find the source of printStackTrace(PrintWriter writer, Thread thread, StackTraceElement[] trace)

Description

print Stack Trace

License

Open Source License

Declaration

private static void printStackTrace(PrintWriter writer, Thread thread, StackTraceElement[] trace) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2012 Google, Inc./*from  www .  j a  v a2 s . co  m*/
 *  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:
 *  Google, Inc. - initial API and implementation
 *******************************************************************************/

import java.io.PrintWriter;

public class Main {
    private static void printStackTrace(PrintWriter writer, Thread thread, StackTraceElement[] trace) {
        try {
            writer.println(thread.toString() + ":");
            for (int i = 0; i < trace.length; i++)
                writer.println("\tat " + trace[i]);
        } catch (Exception e) {
            writer.println("\t*** Exception printing stack trace: " + e);
        }
        writer.flush();
    }
}

Related

  1. printStackTrace(PrintStream out)
  2. printStackTrace(PrintStream out, StackTraceElement[] stackTrace)
  3. printStackTrace(PrintStream printStream, Thread thread, Throwable throwable)
  4. printStackTrace(PrintStream ps)
  5. printStackTrace(PrintStream ps, Exception e)
  6. printStackTrace(StackTraceElement[] elements)
  7. printStackTrace(StackTraceElement[] elements)
  8. printStackTrace(StackTraceElement[] stackTrace)
  9. printStackTrace(StackTraceElement[] stes, String filter)