WriteAbortedException无引入包
继承自ObjectStreamException
该类的类头注释如下:
/** * Signals that one of the ObjectStreamExceptions was thrown during a * write operation. Thrown during a read operation when one of the * ObjectStreamExceptions was thrown during a write operation. The * exception that terminated the write can be found in the detail * field. The stream is reset to it's initial state and all references * to objects already deserialized are discarded. * * <p>As of release 1.4, this exception has been retrofitted to conform to * the general purpose exception-chaining mechanism. The "exception causing * the abort" that is provided at construction time and * accessed via the public {@link #detail} field is now known as the * <i>cause</i>, and may be accessed via the {@link Throwable#getCause()} * method, as well as the aforementioned "legacy field." * * @author unascribed * @since JDK1.1 */
大意如下:
标志着一个ObjectStreamException在写出操作时被抛出
在写入操作过程中抛出 ObjectStreamExceptions 之一时,在读取操作过程中将抛出此异常。终止写入的异常可在详细信息字段中找到。该流被重置为初始状态,而且对已经反序列化的对象的所有引用都被丢弃。
从版本 1.4 开始,已对此异常作出改进,以符合通用异常链机制。在构造时提供并通过公共 detail
字段访问的“导致中止的异常”现在称为 cause,并可通过 Throwable.getCause()
方法以及前述的“遗留字段”访问
该类含有如下的成员变量:
序列化ID
private static final long serialVersionUID = -3326426625597282442L;
异常信息记录
public Exception detail;
该类含有如下的成员方法:
构造方法(异常原因和需要打印出的提示
public WriteAbortedException(String s, Exception ex) { super(s); initCause(null); // Disallow subsequent initCause detail = ex; }
获得异常详细原因(字符串
public String getMessage() { if (detail == null) return super.getMessage(); else return super.getMessage() + "; " + detail.toString(); }
获得异常详细原因(异常类
public Throwable getCause() { return detail; }
该类主要用在记录序列化操作错误,记得使用即可
UTFDataFormatException无引入包
继承自IOException
该类的类头注释如下:
/** * Signals that a malformed string in * <a href="DataInput.html#modified-utf-8">modified UTF-8</a> * format has been read in a data * input stream or by any class that implements the data input * interface. * See the * <a href="DataInput.html#modified-utf-8"><code>DataInput</code></a> * class description for the format in * which modified UTF-8 strings are read and written. * * @author Frank Yellin * @see java.io.DataInput * @see java.io.DataInputStream#readUTF(java.io.DataInput) * @see java.io.IOException * @since JDK1.0 */
大意如下:
在数据输入流中或由实现该数据输入接口的任何类中以 UTF-8 修改版格式读取错误字符串时,抛出此异常。有关读取和写入 UTF-8 修改版字符串的格式,请参阅 DataInput
类的描述。
该类含有如下的成员变量:
序列化ID:
private static final long serialVersionUID = 420743449228280612L;
该类含有如下的成员方法:
构造方法(默认
public UTFDataFormatException() { super(); }
构造方法(带错误信息
public UTFDataFormatException(String s) { super(s); }
该类如注释所说主要用在modified UTF-8类型的字符读取中,注意即可