Here you can find the source of dumpException(String fileName, Throwable t)
Parameter | Description |
---|---|
fileName | a parameter |
t | a parameter |
public static void dumpException(String fileName, Throwable t)
//package com.java2s; import java.io.FileWriter; import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; public class Main { /**//from w w w. j a v a 2 s . com * Method dumpException. * * @param fileName * @param t */ public static void dumpException(String fileName, Throwable t) { dumpException(fileName, t, false); } /** * Method dumpException. * * @param fileName * @param t * @param appendFlag */ public static void dumpException(String fileName, Throwable t, boolean appendFlag) { try { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); Writer fileWriter = new FileWriter(fileName, appendFlag); fileWriter.write(sw.toString()); fileWriter.close(); fileWriter = null; } catch (Throwable t2) { t2.printStackTrace(); } } }