code: private static int writeUncompressedLength(byte[] compressed, int compressedOffset, int uncompressedLength) {
          int highBitMask = 0x80;
          if (uncompressedLength < (1 << 7) && uncompressedLength >= 0) {
              compressed[compressedOffset++] = (byte) (uncompressedLength);
          } else if (uncompressedLength < (1 << 14) && uncompressedLength > 0) {
              compressed[compressedOffset++] = (byte) (uncompressedLength | highBitMask);
              compressed[compressedOffset++] = (byte) (uncompressedLength >>> 7);
          } else if (uncompressedLength < (1 << 21) && uncompressedLength > 0) {
              compressed[compressedOffset++] = (byte) (uncompressedLength | highBitMask);
              compressed[compressedOffset++] = (byte) ((uncompressedLength >>> 7) | highBitMask);
              compressed[compressedOffset++] = (byte) (uncompressedLength >>> 14);
          } else if (uncompressedLength < (1 << 28) && uncompressedLength > 0) {
              compressed[compressedOffset++] = (byte) (uncompressedLength | highBitMask);
              compressed[compressedOffset++] = (byte) ((uncompressedLength >>> 7) | highBitMask);
              compressed[compressedOffset++] = (byte) ((uncompressedLength >>> 14) | highBitMask);
              compressed[compressedOffset++] = (byte) (uncompressedLength >>> 21);
          } else {
              compressed[compressedOffset++] = (byte) (uncompressedLength | highBitMask);
              compressed[compressedOffset++] = (byte) ((uncompressedLength >>> 7) | highBitMask);
              compressed[compressedOffset++] = (byte) ((uncompressedLength >>> 14) | highBitMask);
              compressed[compressedOffset++] = (byte) ((uncompressedLength >>> 21) | highBitMask);
              compressed[compressedOffset++] = (byte) (uncompressedLength >>> 28);
          }
          return compressedOffset;
      }
docs: Writes the uncompressed length as variable length integer.