Package java.io
Interface ObjectOutput
- All Superinterfaces:
AutoCloseable,DataOutput
- All Known Implementing Classes:
ObjectOutputStream
public interface ObjectOutput extends DataOutput, AutoCloseable
Defines an interface for classes that allow reading serialized objects.
- See Also:
ObjectOutputStream,ObjectInput
-
Method Summary
Modifier and Type Method Description voidclose()Closes the target stream.voidflush()Flushes the target stream.voidwrite(byte[] buffer)Writes the entire contents of the byte arraybufferto the output stream.voidwrite(byte[] buffer, int offset, int count)Writescountbytes from the byte arraybufferstarting at positionoffsetto the target stream.voidwrite(int value)Writes a single byte to the target stream.voidwriteObject(Object obj)Writes the specified objectobjto the target stream.Methods inherited from interface java.io.DataOutput
writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
Method Details
-
close
Closes the target stream. Implementations of this method should free any resources used by the stream.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException- if an error occurs while closing the target stream.
-
flush
Flushes the target stream. Implementations of this method should ensure that any pending writes are written out to the target stream.- Throws:
IOException- if an error occurs while flushing the target stream.
-
write
Writes the entire contents of the byte arraybufferto the output stream. Blocks until all bytes are written.- Specified by:
writein interfaceDataOutput- Parameters:
buffer- the buffer to write.- Throws:
IOException- if an error occurs while writing to the target stream.
-
write
Writescountbytes from the byte arraybufferstarting at positionoffsetto the target stream. Blocks until all bytes are written.- Specified by:
writein interfaceDataOutput- Parameters:
buffer- the buffer to write.offset- the index of the first byte inbufferto write.count- the number of bytes frombufferto write to the target stream.- Throws:
IOException- if an error occurs while writing to the target stream.
-
write
Writes a single byte to the target stream. Only the least significant byte of the integervalueis written to the stream. Blocks until the byte is actually written.- Specified by:
writein interfaceDataOutput- Parameters:
value- the byte to write.- Throws:
IOException- if an error occurs while writing to the target stream.- See Also:
DataInput.readByte()
-
writeObject
Writes the specified objectobjto the target stream.- Parameters:
obj- the object to write.- Throws:
IOException- if an error occurs while writing to the target stream.
-