private static void writeOp(byte[] inBuffer,int inOffset,int count,byte[] outBuffer,int write_pos,int buff_len){
  if ((write_pos + count) <= buff_len) {
    System.arraycopy(inBuffer,inOffset,outBuffer,write_pos,count);
  }
 else {
    int tillEndCount;
    int fromStartCount;
    tillEndCount=buff_len - write_pos;
    fromStartCount=count - tillEndCount;
    System.arraycopy(inBuffer,inOffset,outBuffer,write_pos,tillEndCount);
    System.arraycopy(inBuffer,inOffset + tillEndCount,outBuffer,0,fromStartCount);
  }
}

private static void writeOp ( byte [ ] inBuffer , int inOffset , int count , byte [ ] outBuffer , int write_pos , int buff_len ) { if ( ( write_pos + count ) <= buff_len ) { System . arraycopy ( inBuffer , inOffset , outBuffer , write_pos , count ) ; } else { int tillEndCount ; int fromStartCount ; tillEndCount = buff_len - write_pos ; fromStartCount = count - tillEndCount ; System . arraycopy ( inBuffer , inOffset , outBuffer , write_pos , tillEndCount ) ; System . arraycopy ( inBuffer , inOffset + tillEndCount , outBuffer , 0 , fromStartCount ) ; } }
utility method for write operations
