该接口继承自DataInput、AutoCloseable接口
该接口的类头注释如下:
/** * ObjectInput extends the DataInput interface to include the reading of * objects. DataInput includes methods for the input of primitive types, * ObjectInput extends that interface to include objects, arrays, and Strings. * * @author unascribed * @see java.io.InputStream * @see java.io.ObjectOutputStream * @see java.io.ObjectInputStream * @since JDK1.1 */
大意如下:
该类继承自DataInput接口,用来读取Java对象
DataInput包含的方法对应基础数据类型
ObjectInput继承后方法可对应对象、数组和字符串
该类含有如下成员方法:
读取并返回对象
public Object readObject() throws ClassNotFoundException, IOException;
读取单个字节数据(在没有有效数据输入时中断
public int read() throws IOException;
读取数据填充传入的数组(没有效数据中断
public int read(byte b[]) throws IOException;
读取数据填充入数组特定位置
public int read(byte b[], int off, int len) throws IOException;
跳过后续的N个字符进行读取
public long skip(long n) throws IOException;
检验有效数据大小
public int available() throws IOException;
关闭输入流(必须释放流有关资源
public void close() throws IOException;
该类接口从当前来看,比前面的一般输入类接口多了个readObject()方法,在这里感觉可能不是很明显,但是实际上这个方法的出现牵扯到序列化方法的许多知识,下一篇文章我们来分析该类的实例之一:ObjectInputStream

本文介绍了ObjectInput接口,它是DataInput接口的扩展,用于读取Java对象。除了基本数据类型的读取方法外,还新增了readObject()方法,支持读取对象、数组和字符串等复杂类型。文中详细列举了该接口的主要成员方法。
2583

被折叠的 条评论
为什么被折叠?



