Code example for StringWriter

Methods: close, toString

0
    public String getStackTrace(Throwable throwable) {
        String value = null;
        try { 
            StringWriter sw = null;
            try { 
                sw = new StringWriter();
                throwable.printStackTrace(new PrintWriter(sw));
                value = sw.toString();
            } finally { 
                if (sw != null) {
                    sw.close();
                } 
            } 
        } catch (Exception e) {
            value = throwable.getMessage();
        } 
        return value;
    } 
     
    /////////////////////////////////////////////////////////////////////// 
    //