Example #1
0
 /** {@inheritDoc} */
 public void write(OutputStream out) throws IOException {
   // convert all frames to a byte array.
   ByteArrayOutputStream bout = new ByteArrayOutputStream();
   for (Iterator i = frames.values().iterator(); i.hasNext(); ) {
     Frame fr = (Frame) i.next();
     fr.write(bout);
   }
   bout.flush();
   byte[] frameBytes = bout.toByteArray();
   bout.close();
   if (header.usesUnsynchronization()) frameBytes = ByteUtils.unsync(frameBytes);
   header.setDataSize(frameBytes.length);
   header.write(out);
   out.write(frameBytes);
 }