/**
  * Take the data from temporary storage and write it to the output stream
  *
  * @param out output stream output stream
  * @param msgContext messagecontext
  * @throws IOException if an exception occurred while writing data
  */
 private void writeMessageFromTempData(OutputStream out, MessageContext msgContext)
     throws IOException {
   TemporaryData serialized =
       (TemporaryData) msgContext.getProperty(NhttpConstants.SERIALIZED_BYTES);
   try {
     serialized.writeTo(out);
   } finally {
     serialized.release();
   }
 }
 /**
  * Write the stream to a temporary storage and calculate the content length
  *
  * @param entity HTTPEntity
  * @param messageFormatter message formatter
  * @param msgContext current message context
  * @param format message format
  * @throws IOException if an exception occurred while writing data
  */
 private void setStreamAsTempData(
     BasicHttpEntity entity,
     MessageFormatter messageFormatter,
     MessageContext msgContext,
     OMOutputFormat format)
     throws IOException {
   TemporaryData serialized = new TemporaryData(256, 4096, "http-nio_", ".dat");
   OutputStream out = serialized.getOutputStream();
   try {
     messageFormatter.writeTo(msgContext, format, out, true);
   } finally {
     out.close();
   }
   msgContext.setProperty(NhttpConstants.SERIALIZED_BYTES, serialized);
   entity.setContentLength(serialized.getLength());
 }