code: public int write(WritableByteChannel channel) throws IOException {
          // header
          ByteBuffer header = ByteBuffer.allocate(HEADER_LENGTH);
          header.putInt(getSegmentId());
          header.putLong(getSegmentLastForcedTime());
          header.putInt(size());
          
          // footer
          ByteBuffer footer;
          try {
              MessageDigest m = MessageDigest.getInstance("MD5");
              m.reset();
              m.update(header.array());
              m.update(_buffer.array(), 0, _buffer.position());
              byte[] digest = ensure128BitMD5(m.digest());
              
              footer = ByteBuffer.allocate(MD5_LENGTH);
              footer.put(digest);
          } catch (NoSuchAlgorithmException e) {
              throw new IOException(e);
          }
          
          // Write header, data, footer
          header.flip();
          channel.write(header);
          
          channel.write(ByteBuffer.wrap(_buffer.array(), 0, _buffer.position()));
          
          footer.flip();
          channel.write(footer);
          
          return (_buffer.position() + HEADER_FOOTER_LENGTH);
      }
docs: Writes this SegmentIndexBuffer to the specified <code>channel</code>.
  
  @param channel - the writable channel
  @return the number of bytes written to the specified channel.
  @throws IOException