0

Before sending a file to a remote machine, I'm sharding it into multiple smaller pieces locally.

Once the file is split into shards, I write the objects using and ObjectOutputStream. Can I read multiple shard objects from file, using a ObjectInputStream, into a single object? I see no immediate way to append to the ObjectInputStream.

So basically, the flow I'm hoping to have would go:

  • Shard File
    • Split file into multiple shards
    • Write each shard using ooo.writeObject(shard)
    • (e.g., shard.1, shard.2, shard.3, ...)
  • Merge File
    • From a list of shard files, use an ObjectInputStream to read/combine them back into their original object.
MrDuk
  • 16,578
  • 18
  • 74
  • 133
  • There is SequenceInputStream to string multiple InputStreams together. http://stackoverflow.com/questions/14295099/how-to-chain-multiple-different-inputstreams-into-one-inputstream – Thilo Oct 26 '15 at 06:02

1 Answers1

0

Use the same ObjectInputStream and ObjectOutputStream for the entire transmission. Then you can write and read as many objects with them as you like.

OR

Use a new ObjectInputStream per ObjectOutputStream.

user207421
  • 305,947
  • 44
  • 307
  • 483