public void writeLong(final long data,final int numBits){
  if (numBits < 32 && data >= (1 << numBits)) {
    throw new IllegalArgumentException(String.format("Truncating value %d to %d-bit integer",data,numBits));
  }
  for (int i=numBits - 1; i >= 0; i--) {
    boolean bit=(data >> i & 1) != 0;
    if (bit) {
      currentByte|=(1 << currentBitIndex);
    }
    --currentBitIndex;
    if (currentBitIndex < 0) {
      writeCurrentByte();
    }
  }
}

public void writeLong ( final long data , final int numBits ) { if ( numBits < 32 && data >= ( 1 << numBits ) ) { throw new IllegalArgumentException ( String . format ( "Truncating value %d to %d-bit integer" , data , numBits ) ) ; } for ( int i = numBits - 1 ; i >= 0 ; i -- ) { boolean bit = ( data > > i & 1 ) != 0 ; if ( bit ) { currentByte |= ( 1 << currentBitIndex ) ; } -- currentBitIndex ; if ( currentBitIndex < 0 ) { writeCurrentByte ( ) ; } } }
writes a sequence of bits to the stream .
