您的位置:首页 > 移动开发 > Objective-C

Java 日看一类(35)之IO包中的ObjectInput接口

2018-03-28 10:31 281 查看
该接口继承自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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: