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 Details

    • close

      void close() throws IOException
      Closes the target stream. Implementations of this method should free any resources used by the stream.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException - if an error occurs while closing the target stream.
    • flush

      void flush() throws IOException
      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

      void write​(byte[] buffer) throws IOException
      Writes the entire contents of the byte array buffer to the output stream. Blocks until all bytes are written.
      Specified by:
      write in interface DataOutput
      Parameters:
      buffer - the buffer to write.
      Throws:
      IOException - if an error occurs while writing to the target stream.
    • write

      void write​(byte[] buffer, int offset, int count) throws IOException
      Writes count bytes from the byte array buffer starting at position offset to the target stream. Blocks until all bytes are written.
      Specified by:
      write in interface DataOutput
      Parameters:
      buffer - the buffer to write.
      offset - the index of the first byte in buffer to write.
      count - the number of bytes from buffer to write to the target stream.
      Throws:
      IOException - if an error occurs while writing to the target stream.
    • write

      void write​(int value) throws IOException
      Writes a single byte to the target stream. Only the least significant byte of the integer value is written to the stream. Blocks until the byte is actually written.
      Specified by:
      write in interface DataOutput
      Parameters:
      value - the byte to write.
      Throws:
      IOException - if an error occurs while writing to the target stream.
      See Also:
      DataInput.readByte()
    • writeObject

      void writeObject​(Object obj) throws IOException
      Writes the specified object obj to the target stream.
      Parameters:
      obj - the object to write.
      Throws:
      IOException - if an error occurs while writing to the target stream.