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

该接口继承自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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值