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
该接口的类头注释如下:/**
* 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
相关文章推荐
- Java 日看一类(16) 之IO包中的FileDescriptor类
- Java 日看一类(3)之IO包中的BufferedOutputStream类
- Java 日看一类(5)之IO包中的BufferedWriter类
- Java 日看一类(27)之IO包中的FIlterWriter类
- Java 日看一类(14)之IO包中的EOFException异常类和ExpiringCache内部类
- Java 日看一类(22)之IO包中的FileSystem类(抽象类
- Java 日看一类 (33)之IO包中的LineNumberReader类
- Java 日看一类(30)之IO包中的InterruptedIOException、InvalidObjectException异常类
- Java 日看一类(26)之IO包中的FilterReader类
- Java 日看一类(18)之IO包中的FileNameFilter接口类和FileNotFoundException异常类
- Java 日看一类(4)之IO包中的BufferedReader类
- Java 日看一类(31)之IO包中的InvalidClassException异常类和IOError异常类
- Java 日看一类(34)之IO包中的NotActiveException和NotSerializableException
- Java 日看一类(23)之IO包中的FileWriter类
- Java日看一类(2)之IO包中的BufferedInputStream类
- Java 日看一类(13)之IO包中的DefaultFileSystem类和DeleteOnExitHook类
- Java 日看一类(6)之IO包中的ByteArrayInputStream类
- Java 日看一类(32)之IO包中的IOException类
- Java 日看一类(25)之IO包中的FilterOutputStream类
- Java 日看一类(7)之IO包中的ByteArrayOutputStream类