public static int inflate(byte[] previous,int previousLength,byte[] current,int currentLength,byte[] result){
  if (previous == null) {
    System.arraycopy(current,0,result,0,currentLength);
    return currentLength;
  }
  int length=0;
  int start1=0;
  int start2=0;
  while (start1 < previousLength && start2 < currentLength) {
    int end1=start1;
    while (end1 < previousLength && previous[end1] != '\t') {
      end1++;
    }
    int end2=start2;
    while (end2 < currentLength && current[end2] != '\t') {
      end2++;
    }
    if (current[start2] == '&' && end2 == start2 + 1) {
      for (int i=start1; i < end1; i++)       result[length++]=previous[i];
    }
 else {
      for (int i=start2; i < end2; i++)       result[length++]=current[i];
    }
    if (end2 < currentLength)     result[length++]='\t';
    start1=end1 + 1;
    start2=end2 + 1;
  }
  return length;
}

public static int inflate ( byte [ ] previous , int previousLength , byte [ ] current , int currentLength , byte [ ] result ) { if ( previous == null ) { System . arraycopy ( current , 0 , result , 0 , currentLength ) ; return currentLength ; } int length = 0 ; int start1 = 0 ; int start2 = 0 ; while ( start1 < previousLength && start2 < currentLength ) { int end1 = start1 ; while ( end1 < previousLength && previous [ end1 ] != '\t' ) { end1 ++ ; } int end2 = start2 ; while ( end2 < currentLength && current [ end2 ] != '\t' ) { end2 ++ ; } if ( current [ start2 ] == '&' && end2 == start2 + 1 ) { for ( int i = start1 ; i < end1 ; i ++ ) result [ length ++ ] = previous [ i ] ; } else { for ( int i = start2 ; i < end2 ; i ++ ) result [ length ++ ] = current [ i ] ; } if ( end2 < currentLength ) result [ length ++ ] = '\t' ; start1 = end1 + 1 ; start2 = end2 + 1 ; } return length ; }
inflate the current sam line by replacing all & by the corresponding field in the previous sam line
