Class ObjectOutputStream

java.lang.Object
dev.gmitch215.bytebox.io.ObjectOutputStream
All Implemented Interfaces:
AutoCloseable

public class ObjectOutputStream extends Object implements AutoCloseable
Writes objects in Java's serialization format, standing in for java.io.ObjectOutputStream.

The compiler substitutes the class library's for this one, which the class library does not have at all, so a library that serialises the ordinary way works unchanged.

 ByteArrayOutputStream bytes = new ByteArrayOutputStream();
 try (ObjectOutputStream out = new ObjectOutputStream(bytes)) {
 	out.writeObject(new Order("abc", 2, 3L));
 }

One object per stream. A JVM writes a header once and then any number of objects, sharing the handle table between them; here each writeObject(java.lang.Object) is a complete stream, so writing twice throws rather than producing bytes a reader would misread.

Every type written needs a codec, which the build writes for anything annotated SerialType. Serial is the same thing without a stream in the way.

Since:
1.0.0
  • Constructor Details

    • ObjectOutputStream

      public ObjectOutputStream(OutputStream out)
      Parameters:
      out - where the bytes go
  • Method Details