Java Log to Stream logCallStack(PrintStream out)

Here you can find the source of logCallStack(PrintStream out)

Description

log Call Stack

License

Open Source License

Declaration

public static void logCallStack(PrintStream out) 

Method Source Code

//package com.java2s;
/* /*w  ww.  ja  va  2  s . c om*/
 * This file is part of the HyperGraphDB source distribution. This is copyrighted 
 * software. For permitted uses, licensing options and redistribution, please see  
 * the LicensingInformation file at the root level of the distribution.  
 * 
 * Copyright (c) 2005-2010 Kobrix Software, Inc.  All rights reserved. 
 */

import java.io.PrintStream;

public class Main {
    public static void logCallStack(PrintStream out) {
        printStackTrace(Thread.currentThread().getStackTrace(), out);
    }

    /**
     * <p>
     * Print the full stack trace of a <code>Throwable</code> object into a
     * string buffer and return the corresponding string.  
     * </p>
     */
    public static String printStackTrace(Throwable t) {
        java.io.StringWriter strWriter = new java.io.StringWriter();
        java.io.PrintWriter prWriter = new java.io.PrintWriter(strWriter);
        t.printStackTrace(prWriter);
        prWriter.flush();
        return strWriter.toString();
    }

    public static void printStackTrace(StackTraceElement[] trace,
            PrintStream out) {
        for (StackTraceElement el : trace)
            out.println(el.toString());
    }
}

Related

  1. logToStream(OutputStream o)