Package java.io
Interface ObjectInput
- All Superinterfaces:
AutoCloseable,DataInput
- All Known Implementing Classes:
ObjectInputStream
public interface ObjectInput extends DataInput, AutoCloseable
Defines an interface for classes that allow reading serialized objects.
- See Also:
ObjectInputStream,ObjectOutput
-
Method Summary
Modifier and Type Method Description intavailable()Indicates the number of bytes of primitive data that can be read without blocking.voidclose()Closes this stream.intread()Reads a single byte from this stream and returns it as an integer in the range from 0 to 255.intread(byte[] buffer)Reads bytes from this stream into the byte arraybuffer.intread(byte[] buffer, int byteOffset, int byteCount)Reads up tobyteCountbytes from this stream and stores them in byte arraybufferstarting at offsetbyteOffset.ObjectreadObject()Reads the next object from this stream.longskip(long byteCount)SkipsbyteCountbytes on this stream.Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
-
Method Details
-
available
Indicates the number of bytes of primitive data that can be read without blocking.- Returns:
- the number of bytes available.
- Throws:
IOException- if an I/O error occurs.
-
close
Closes this stream. Implementations of this method should free any resources used by the stream.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException- if an I/O error occurs while closing the input stream.
-
read
Reads a single byte from this stream and returns it as an integer in the range from 0 to 255. Returns -1 if the end of this stream has been reached. Blocks if no input is available.- Returns:
- the byte read or -1 if the end of this stream has been reached.
- Throws:
IOException- if this stream is closed or another I/O error occurs.
-
read
Reads bytes from this stream into the byte arraybuffer. Blocks while waiting for input. Returns the number of bytes read, or -1 if the end of this stream has been reached.- Throws:
IOException- if this stream is closed or another I/O error occurs.
-
read
Reads up tobyteCountbytes from this stream and stores them in byte arraybufferstarting at offsetbyteOffset. Blocks while waiting for input. Returns the number of bytes read or -1 if the end of this stream has been reached.- Throws:
IOException- if this stream is closed or another I/O error occurs.
-
readObject
Reads the next object from this stream.- Returns:
- the object read.
- Throws:
ClassNotFoundException- if the object's class cannot be found.IOException- if this stream is closed or another I/O error occurs.
-
skip
SkipsbyteCountbytes on this stream. Less thanbyteCountbyte are skipped if the end of this stream is reached before the operation completes.- Returns:
- the number of bytes actually skipped.
- Throws:
IOException- if this stream is closed or another I/O error occurs.
-