@Override
  public long writeTo(Write writeChannel) throws StoreException {
    ReadableByteChannel readableByteChannel = Channels.newChannel(streamToWrite);
    long sizeWritten = 0;
    for (MessageInfo info : streamInfo) {
      writeChannel.appendFrom(readableByteChannel, info.getSize());
      sizeWritten += info.getSize();
    }
    return sizeWritten;
  }
A message write set that writes to the underlying write interface
ambry-messageformat/src/main/java/com/github/ambry/messageformat/MessageFormatWriteSet.java