Appending to an ObjectOutputStream

前端 未结 6 1509
再見小時候
再見小時候 2020-11-22 03:00

Is it not possible to append to an ObjectOutputStream?

I am trying to append to a list of objects. Following snippet is a function that is called whenev

6条回答
  •  盖世英雄少女心
    2020-11-22 03:43

    Because of the precise format of the serialized file, appending will indeed corrupt it. You have to write all objects to the file as part of the same stream, or else it will crash when it reads the stream metadata when it's expecting an object.

    You could read the Serialization Specification for more details, or (easier) read this thread where Roedy Green says basically what I just said.

提交回复
热议问题