public static int checkVlen(int i) {
    int count = 0;
    if (i >= -112 && i <= 127) {
      return 1;
    } else {
      int len = -112;
      if (i < 0) {
        i ^= -1L; // take one's complement'
        len = -120;
      }

      long tmp = i;
      while (tmp != 0) {
        tmp = tmp >> 8;
        len--;
      }

      count++;

      len = (len < -120) ? -(len + 120) : -(len + 112);

      while (len != 0) {
        count++;
        len--;
      }

      return count;
    }
  }
public static int checkVlen ( int i ) { int count = 0 ; if ( i >= - 112 && i <= 127 ) { return 1 ; } else { int len = - 112 ; if ( i < 0 ) { i ^= - 1L ; len = - 120 ; } long tmp = i ; while ( tmp != 0 ) { tmp = tmp > > 8 ; len -- ; } count ++ ; len = ( len < - 120 ) ? - ( len + 120 ) : - ( len + 112 ) ; while ( len != 0 ) { count ++ ; len -- ; } return count ; } }
Determines the number bytes required to store a variable length

@param i length of Bytes
@return number of bytes needed