Package java.io

Class ObjectOutputStream

java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput, ObjectStreamConstants, AutoCloseable

public class ObjectOutputStream
extends OutputStream
implements ObjectOutput, ObjectStreamConstants
A specialized OutputStream that is able to write (serialize) Java objects as well as primitive data types (int, byte, char etc.). The data can later be loaded using an ObjectInputStream.
See Also:
ObjectInputStream, ObjectOutput, Serializable, Externalizable
  • Constructor Details

    • ObjectOutputStream

      protected ObjectOutputStream() throws IOException
      Constructs a new ObjectOutputStream. This default constructor can be used by subclasses that do not want to use the public constructor if it allocates unneeded data.
      Throws:
      IOException - if an error occurs when creating this stream.
    • ObjectOutputStream

      public ObjectOutputStream​(OutputStream output) throws IOException
      Constructs a new ObjectOutputStream that writes to the OutputStream output.
      Parameters:
      output - the non-null OutputStream to filter writes on.
      Throws:
      IOException - if an error occurs while writing the object stream header
  • Method Details