throwable.html

来自「API資料大全」· HTML 代码 · 共 482 行 · 第 1/2 页

HTML
482
字号
Throwable</H3><PRE>public <B>Throwable</B>()</PRE><DL><DD>Constructs a new <code>Throwable</code> with <code>null</code> as  its error message string. Also, the method  <A HREF="../../java/lang/Throwable.html#fillInStackTrace()"><CODE>fillInStackTrace()</CODE></A> is called for this object.</DL><HR><A NAME="Throwable(java.lang.String)"><!-- --></A><H3>Throwable</H3><PRE>public <B>Throwable</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;message)</PRE><DL><DD>Constructs a new <code>Throwable</code> with the specified error  message. Also, the method <A HREF="../../java/lang/Throwable.html#fillInStackTrace()"><CODE>fillInStackTrace()</CODE></A> is called for  this object.<DD><DL><DT><B>Parameters:</B><DD><CODE>message</CODE> - the error message. The error message is saved for           later retrieval by the <A HREF="../../java/lang/Throwable.html#getMessage()"><CODE>getMessage()</CODE></A> method.</DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getMessage()"><!-- --></A><H3>getMessage</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getMessage</B>()</PRE><DL><DD>Returns the error message string of this throwable object.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the error message string of this <code>Throwable</code>           object if it was <A HREF="../../java/lang/Throwable.html#Throwable(java.lang.String)"><CODE>created</CODE></A> with an           error message string; or <code>null</code> if it was           <A HREF="../../java/lang/Throwable.html#Throwable()"><CODE>created</CODE></A> with no error message.</DL></DD></DL><HR><A NAME="getLocalizedMessage()"><!-- --></A><H3>getLocalizedMessage</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getLocalizedMessage</B>()</PRE><DL><DD>Creates a localized description of this <code>Throwable</code>. Subclasses may override this method in order to produce a locale-specific message.  For subclasses that do not override this method, the default implementation returns the same result as <code>getMessage()</code>.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>The localized description of this <code>Throwable</code>.<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns a short description of this throwable object. If this <code>Throwable</code> object was  <A HREF="../../java/lang/Throwable.html#Throwable(java.lang.String)"><CODE>created</CODE></A> with an error message string,  then the result is the concatenation of three strings:  <ul> <li>The name of the actual class of this object  <li>": " (a colon and a space)  <li>The result of the <A HREF="../../java/lang/Throwable.html#getMessage()"><CODE>getMessage()</CODE></A> method for this object  </ul> If this <code>Throwable</code> object was <A HREF="../../java/lang/Throwable.html#Throwable()"><CODE>created</CODE></A>  with no error message string, then the name of the actual class of  this object is returned.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of this <code>Throwable</code>.</DL></DD></DL><HR><A NAME="printStackTrace()"><!-- --></A><H3>printStackTrace</H3><PRE>public void <B>printStackTrace</B>()</PRE><DL><DD>Prints this <code>Throwable</code> and its backtrace to the  standard error stream. This method prints a stack trace for this  <code>Throwable</code> object on the error output stream that is  the value of the field <code>System.err</code>. The first line of  output contains the result of the <A HREF="../../java/lang/Throwable.html#toString()"><CODE>toString()</CODE></A> method for  this object. Remaining lines represent data previously recorded by  the method <A HREF="../../java/lang/Throwable.html#fillInStackTrace()"><CODE>fillInStackTrace()</CODE></A>. The format of this  information depends on the implementation, but the following  example may be regarded as typical:  <blockquote><pre> java.lang.NullPointerException         at MyClass.mash(MyClass.java:9)         at MyClass.crunch(MyClass.java:6)         at MyClass.main(MyClass.java:3) </pre></blockquote> This example was produced by running the program:  <blockquote><pre>  class MyClass {      public static void main(String[] argv) {         crunch(null);     }     static void crunch(int[] a) {         mash(a);     }      static void mash(int[] b) {         System.out.println(b[0]);     } } </pre></blockquote><DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../java/lang/System.html#err"><CODE>System.err</CODE></A></DL></DD></DL><HR><A NAME="printStackTrace(java.io.PrintStream)"><!-- --></A><H3>printStackTrace</H3><PRE>public void <B>printStackTrace</B>(<A HREF="../../java/io/PrintStream.html">PrintStream</A>&nbsp;s)</PRE><DL><DD>Prints this <code>Throwable</code> and its backtrace to the  specified print stream.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - <code>PrintStream</code> to use for output</DL></DD></DL><HR><A NAME="printStackTrace(java.io.PrintWriter)"><!-- --></A><H3>printStackTrace</H3><PRE>public void <B>printStackTrace</B>(<A HREF="../../java/io/PrintWriter.html">PrintWriter</A>&nbsp;s)</PRE><DL><DD>Prints this <code>Throwable</code> and its backtrace to the specified print writer.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - <code>PrintWriter</code> to use for output<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="fillInStackTrace()"><!-- --></A><H3>fillInStackTrace</H3><PRE>public <A HREF="../../java/lang/Throwable.html">Throwable</A> <B>fillInStackTrace</B>()</PRE><DL><DD>Fills in the execution stack trace. This method records within this  <code>Throwable</code> object information about the current state of  the stack frames for the current thread. This method is useful when  an application is re-throwing an error or exception. For example:  <p><blockquote><pre>     try {         a = b / c;     } catch(ArithmeticThrowable e) {         a = Double.MAX_VALUE;         throw e.fillInStackTrace();     } </pre></blockquote><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>this <code>Throwable</code> object.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Throwable.html#printStackTrace()"><CODE>printStackTrace()</CODE></A></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Throwable.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../java/lang/ThreadLocal.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../java/lang/Void.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="Throwable.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation  contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A.  All Rights Reserved.</font></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?