code: static void writeInt(final int value, final DataOutput out) throws IOException {
  		// Zig-zag encoding.
  		int n = (value << 1)^(value >> 31);
  		if ((n & ~0x7F) != 0) {
  			out.write((byte)((n | 0x80) & 0xFF));
  			n >>>= 7;
  			if (n > 0x7F) {
  				out.write((byte)((n | 0x80) & 0xFF));
  				n >>>= 7;
  				if (n > 0x7F) {
  					out.write((byte)((n | 0x80) & 0xFF));
  					n >>>= 7;
  					if (n > 0x7F) {
  						out.write((byte)((n | 0x80) & 0xFF));
  						n >>>= 7;
  					}
  				}
  			}
  		}
  		out.write((byte)n);
  	}
docs: Writes an int value to a series of bytes. The values are written using
  <a href="http://lucene.apache.org/core/3_5_0/fileformats.html#VInt">variable-length</a>
  <a href="https://developers.google.com/protocol-buffers/docs/encoding?csw=1#types">zig-zag</a>
  coding. Each {@code int} value is written in 1 to 5 bytes.
  
  @see #readInt(DataInput)
  
  @param value the integer value to write
  @param out the data output the integer value is written to
  @throws NullPointerException if the given data output is {@code null}
  @throws IOException if an I/O error occurs