楼上说的对,在java中还有许多这样的转换。像Object等都可以用toString()
方法。

解决方案 »

  1.   

    其实捕捉违例的时候比如
    catch(Exception) {
      System.out.println(e);
    }
    此时e就应该已经内部处理成为String类型的字符串数据了
      

  2.   

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

  3.   

    怎样捕获Error,而不是Exception
    Error: URI=file:d:/200205230839.xml Line=5: Element type "Item111" must be declared.Error: URI=file:d:/200205230839.xml Line=5: The content of element type "Item" must match "(ItemName,UnitPrice,Quantity,Amount)".
      

  4.   

    An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a "normal" condition, is also a subclass of Error because most applications should not try to catch it. A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur.