コード例 #1
0
        private static String getStackTraceString(Exception tr)
        {
            if (tr == null)
            {
                return("");
            }

            // This is to reduce the amount of log spew that apps do in the non-error
            // condition of the network being unavailable.
            Throwable t = tr;

            while (t != null)
            {
                if (t instanceof UnknownHostException)
                {
                    return("");
                }
                t = t.getCause();
            }

            StringWriter sw = new StringWriter();
            StreamReader pw = new StreamReader(sw);

            tr.printStackTrace(pw);
            pw.flush();
            return(sw.toString());
        }