Java Stacktrace Print printStackTrace()

Here you can find the source of printStackTrace()

Description

print Stack Trace

License

Open Source License

Declaration

public static String printStackTrace() 

Method Source Code

//package com.java2s;
/* //from  ww w.  ja v  a 2  s .com
    
 Created on Mar 4, 2005
    
 The Bungee View applet lets you search, browse, and data-mine an image collection.  
 Copyright (C) 2006  Mark Derthick
    
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.  See gpl.html.
    
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
    
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    
 You may also contact the author at 
 mad@cs.cmu.edu, 
 or at
 Mark Derthick
 Carnegie-Mellon University
 Human-Computer Interaction Institute
 Pittsburgh, PA 15213
    
 */

import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    public static String printStackTrace() {
        (new RuntimeException("Relax.  There's no error, we're just printing the stack trace")).printStackTrace();
        return null;
    }

    public static String printStackTrace(Throwable e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        return sw.toString();
    }
}

Related

  1. printStackTrace()
  2. printStackTrace()
  3. printStackTrace()
  4. printStackTrace()
  5. printStackTrace()
  6. printStackTrace()
  7. printStackTrace()
  8. printStackTrace()
  9. printStackTrace()