Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/* 
 * 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());
    }
}