code: public static int writeLength(int valueLength, OutputStream out) throws IOException {
          if (valueLength < 128) {
              out.write(valueLength);
              return 1;
          } else if (valueLength < 16384) {
              out.write((valueLength >> 8) | 0x80);
              out.write(valueLength);
              return 2;
          } else if (valueLength < 2097152) {
              out.write((valueLength >> 16) | 0xc0);
              out.write(valueLength >> 8);
              out.write(valueLength);
              return 3;
          } else if (valueLength < 268435456) {
              out.write((valueLength >> 24) | 0xe0);
              out.write(valueLength >> 16);
              out.write(valueLength >> 8);
              out.write(valueLength);
              return 4;
          } else {
              out.write(0xf0);
              out.write(valueLength >> 24);
              out.write(valueLength >> 16);
              out.write(valueLength >> 8);
              out.write(valueLength);
              return 5;
          }
      }
docs: Writes a positive length value in up to five bytes.
  
  @return number of bytes written
  @since 1.2