这次讲述的类可能有一点多,不过每个类的内容都比较少(异常类没多少内容代码)
InterruptedException类无引入包
继承自IOException
类头注释如下
/** * Signals that an I/O operation has been interrupted. An * <code>InterruptedIOException</code> is thrown to indicate that an * input or output transfer has been terminated because the thread * performing it was interrupted. The field {@link #bytesTransferred} * indicates how many bytes were successfully transferred before * the interruption occurred. * * @author unascribed * @see java.io.InputStream * @see java.io.OutputStream * @see java.lang.Thread#interrupt() * @since JDK1.0 */
大意如下:
该异常类标志着IO操作被意外终止
该类标志着输入输出操作由于线程运行被打断而终止
参数byteTransFerred记录了在该异常抛出前有多少byte数据成功进行交互运输
该类含有入下的成员变量:
串行序列号:
private static final long serialVersionUID = 4020568460727500567L;
交互数据记录器
public int bytesTransferred = 0;
该类含有如下的成员方法:
构造函数(无特殊显示错误原因
public InterruptedIOException() { super(); }
构造函数(显示特定原因
public InterruptedIOException(String s) { super(s); }
该类会在IO操作意外中断时被抛出,遇到该类异常时可以通过查看该类的计数器来判断中断错误是来自程序内部还是程序外部(多次运行查看计数器
InvaliedObjectException无引入包
继承自ObjectStreamException
类头注释如下:
/** * Indicates that one or more deserialized objects failed validation * tests. The argument should provide the reason for the failure. * * @see ObjectInputValidation * @since JDK1.1 * * @author unascribed * @since JDK1.1 */
大意如下:
标志一个或更多的反序列化对象未通过验证测试
应当提供错误原因参数
该类含有如下的成员变量:
序列化ID
private static final long serialVersionUID = 3233174318281839583L;
构造函数(传入错误原因
public InvalidObjectException(String reason) { super(reason); }
该类的使用一般是二进制流出错或遗漏时抛出,或者是序列化版本和当前系统对象版本不同(不过这种一般也就抛出Class错误),注意下就好了