public String getMessages (boolean elideNewlines, Locale locale)
public String getMessages()
    public String getMessages (boolean elideNewlines, Locale locale)    {        StringWriter  sw = new StringWriter();        PrintWriter   pw = new PrintWriter (sw);        Throwable     ex = this;        StringBuffer  buf = null;        if (locale == null)            locale = Locale.getDefault();        if (elideNewlines)            buf = new StringBuffer();        // Note: Last exception message dumped should not have a newline.        while (ex != null)        {            String s;            if (ex instanceof NestedException)                s = ((NestedException) ex).getMessage (locale);            else                s = ex.getMessage();            if (s == null)                s = ex.toString();            if (elideNewlines)            {                // Must remove any newlines in this message,                try                {                    LineNumberReader r = new LineNumberReader                                           (new StringReader (s));                    String line;                    String sep = "";                    buf.setLength (0);                    while ((line = r.readLine()) != null)                    {                        buf.append (sep);                        buf.append (line);                        sep = " ";                    }                    s = buf.toString();                }                catch (IOException ioEx)                {                    // Shouldn't happen. If it does, just use the original                    // string.                }            }            // Add the message to the buffer            pw.print (s);            if (! (ex instanceof NestedException))                break;            ex = ((NestedException) ex).getNestedException();            if (ex != null)            {                if (elideNewlines)                    pw.print (": ");                else                    pw.println();            }        }        return sw.getBuffer().toString();    }