JavaTM 2 Platform
Standard Ed. 6

java.io
接口 ObjectInput

所有超级接口:
DataInput
所有已知实现类:
ObjectInputStream

public interface ObjectInput
extends DataInput

ObjectInput 扩展 DataInput 接口以包含对象的读操作。DataInput 包括基本类型的输入方法;ObjectInput 扩展了该接口,以包含对象、数组和 String 的输出方法。

从以下版本开始:
JDK1.1
另请参见:
InputStream, ObjectOutputStream, ObjectInputStream

方法摘要
 int available()
          返回可以无阻塞地读取的字节数。
 void close()
          关闭输入流。
 int read()
          读取数据字节。
 int read(byte[] b)
          读入 byte 数组。
 int read(byte[] b, int off, int len)
          读入 byte 数组。
 Object readObject()
          读取并返回对象。
 long skip(long n)
          跳过输入的 n 个字节。
 
从接口 java.io.DataInput 继承的方法
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
 

方法详细信息

readObject

Object readObject()
                  throws ClassNotFoundException,
                         IOException
读取并返回对象。实现此接口的类定义从哪里“读取”对象。

返回:
从流读取的对象
抛出:
ClassNotFoundException - 如果无法找到已序列化对象的类。
IOException - 如果发生任何常规 Input/Output 相关的异常。

read

int read()
         throws IOException
读取数据字节。如果不存在可用的输入,此方法将发生阻塞。

返回:
读取的字节;如果已到达流的末尾,则返回 -1。
抛出:
IOException - 如果发生 I/O 错误。

read

int read(byte[] b)
         throws IOException
读入 byte 数组。在某些输入可用之前,此方法将发生阻塞。

参数:
b - 将数据读入的缓冲区
返回:
读取的实际字节数;当到达流的末尾时,返回 -1。
抛出:
IOException - 如果发生 I/O 错误。

read

int read(byte[] b,
         int off,
         int len)
         throws IOException
读入 byte 数组。在某些输入可用之前,此方法将发生阻塞。

参数:
b - 将数据读入的缓冲区
off - 数据的初始偏移量
len - 读取的最大字节数
返回:
读取的实际字节数;当到达流的末尾时返回 -1。
抛出:
IOException - 如果发生 I/O 错误。

skip

long skip(long n)
          throws IOException
跳过输入的 n 个字节。

参数:
n - 要跳过的字节数
返回:
跳过的实际字节数。
抛出:
IOException - 如果发生 I/O 错误。

available

int available()
              throws IOException
返回可以无阻塞地读取的字节数。

返回:
可用字节数。
抛出:
IOException - 如果发生 I/O 错误。

close

void close()
           throws IOException
关闭输入流。必须调用此方法以释放与流相关的所有资源。

抛出:
IOException - 如果发生 I/O 错误。

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only