public byte[] toByteArray(){
  try {
    ByteArrayOutputStream outBytes=new ByteArrayOutputStream();
    DataOutputStream dataStream=new DataOutputStream(outBytes);
    if (isFinalFrame_) {
      dataStream.writeInt(Constants.ENDFRAME_SEQUENCE_NUMBER);
    }
    dataStream.writeInt(sequenceNumber_);
    dataStream.write(nonce_);
    if (includeFrameSize_ || isFinalFrame_) {
      dataStream.writeInt(frameContentLength_);
    }
    dataStream.close();
    return outBytes.toByteArray();
  }
 catch (  IOException e) {
    throw new RuntimeException("Failed to serialize cipher frame headers",e);
  }
}

public byte [ ] toByteArray ( ) { try { ByteArrayOutputStream outBytes = new ByteArrayOutputStream ( ) ; DataOutputStream dataStream = new DataOutputStream ( outBytes ) ; if ( isFinalFrame_ ) { dataStream . writeInt ( Constants . ENDFRAME_SEQUENCE_NUMBER ) ; } dataStream . writeInt ( sequenceNumber_ ) ; dataStream . write ( nonce_ ) ; if ( includeFrameSize_ || isFinalFrame_ ) { dataStream . writeInt ( frameContentLength_ ) ; } dataStream . close ( ) ; return outBytes . toByteArray ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "Failed to serialize cipher frame headers" , e ) ; } }
serialize the header into a byte array .
