Convert an integer to an array of byte.

@param value The integer value.
@return The byte array.
330613
public static byte[] intToByteArray(int value)
    {
        return new byte[]
        {
            (byte) (value >>> Constant.BYTE_4), (byte) (value >>> Constant.BYTE_3), (byte) (value >>> Constant.BYTE_2),
            (byte) value
        };
    }
551838
public R toBytesArray(@Nullable Iterable<ByteArray> values) {
    return handle(Value.bytesArray(values));
  }
1031954
public static int bytesToInt(final byte[] arr) {
    int v = 0;
    for (int i = 0; i < 4; i++) {
      v |= (arr[i] & 0XFF) << (i * 8);
    }
    return v;
  }
1119660
static public byte[] asByteArray(int value) {

        // check for 0
        if (0 == value) {
            return ZERO_BYTEARRAY;
        }

        // 2^31 is a 10 digit number so make space for the max size
        byte[] bytes = new byte[SIZE_MAXINT];
        // check for negative ints
        boolean bNegative = false;
        if (0 > value) {
            // force it positive for parsing
            bNegative = true;
            value = -value;
        }
        // now loop back through each digit in the int
        int index = SIZE_MAXINT - 1;
        for (; 0 <= index && 0 != value; index--) {
            bytes[index] = HEX_BYTES[value % 10];
            value /= 10;
        }

        // length is how ever many digits there were + a possible negative sign
        int len = (SIZE_MAXINT - 1 - index);
        if (bNegative) {
            len++;
        }

        // now copy out the "real bytes" for returning
        byte[] realBytes = new byte[len];
        for (int i = len - 1, x = SIZE_MAXINT - 1; 0 <= i; i--, x--) {
            realBytes[i] = bytes[x];
        }
        // add negative sign if we need to
        if (bNegative) {
            realBytes[0] = '-';
        }
        return realBytes;
    }
204855
public static String toHexString(byte[] value) {
    String newString = "";
    for (int i = 0; i < value.length; i++) {
      byte b = value[i];
      String str = Integer.toHexString(b);
      if (str.length() > 2) {
        str = str.substring(str.length() - 2);
      }
      if (str.length() < 2) {
        str = "0" + str;
      }
      newString += str;
    }
    return newString.toUpperCase();
  }
777950
public static ByteBuf copyInt(int value) {
        ByteBuf buf = buffer(4);
        buf.writeInt(value);
        return buf;
    }
600502
public byte[] toByteArray() {
		byte[] raw = new byte[8];
		byte[] bi = bigIntValue().toByteArray();
		System.arraycopy(bi, 0, raw, raw.length - bi.length, bi.length);
		return raw;
	}
1199430
public void packInt(int value) throws IOException {
        ensureAvail(5); //ensure worst case bytes

        // Optimize for the common case where value is small. This is particular important where our caller
        // is SerializerBase.SER_STRING.serialize because most chars will be ASCII characters and hence in this range.
        // credit Max Bolingbroke https://github.com/jankotek/MapDB/pull/489
        int shift = (value & ~0x7F); //reuse variable
        if (shift != 0) {
            shift = 31 - Integer.numberOfLeadingZeros(value);
            shift -= shift % 7; // round down to nearest multiple of 7
            while (shift != 0) {
                buf[pos++] = (byte) ((value >>> shift) & 0x7F);
                shift -= 7;
            }
        }
        buf[pos++] = (byte) ((value & 0x7F)| 0x80);
    }
1360617
public Integer convertToInt(String value) {
        Integer result = null;
        if (value != null) {
            result = Integer.valueOf(value);
        }
        return result;
    }
822001
public static byte[] toArray(Collection<? extends Number> bytes) {
    byte[] array = new byte[bytes.size()];
    Iterator<? extends Number> iter = bytes.iterator();
    for (int i = 0; i < bytes.size(); i++) {
      array[i] = iter.next().byteValue();
    }
    return array;
  }
97879
public static Byte[] wrap(byte... values) {
		if (null == values) {
			return null;
		}
		final int length = values.length;
		if (0 == length) {
			return new Byte[0];
		}

		final Byte[] array = new Byte[length];
		for (int i = 0; i < length; i++) {
			array[i] = Byte.valueOf(values[i]);
		}
		return array;
	}
1198357
private static byte[] toBytes(Object input) {
        if (input instanceof byte[]) {
            return (byte[]) input;
        } else if (input instanceof String) {
            String inputString = (String) input;
            return inputString.getBytes();
        } else if (input instanceof Long) {
            Long inputLong = (Long) input;
            return (inputLong == 0) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(BigInteger.valueOf(inputLong));
        } else if (input instanceof Integer) {
            Integer inputInt = (Integer) input;
            return (inputInt == 0) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(BigInteger.valueOf(inputInt));
        } else if (input instanceof BigInteger) {
            BigInteger inputBigInt = (BigInteger) input;
            return (inputBigInt.equals(BigInteger.ZERO)) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(inputBigInt);
        }
        throw new RuntimeException("Unsupported type: Only accepting String, Integer and BigInteger for now");
    }
1232169
public static byte[] toBytes(int value) {
		final byte[] result = new byte[4];

		result[0] = (byte) (value >> 24);
		result[1] = (byte) (value >> 16);
		result[2] = (byte) (value >> 8);
		result[3] = (byte) (value /* >> 0 */);

		return result;
	}
1190842
public static byte[] asciiBytes(String value) {
    Preconditions.checkNotNull(value);
    try {
      return value.getBytes("ASCII");
    } catch (UnsupportedEncodingException uee) {
      // won't happen
      throw new RuntimeException("ASCII not found!", uee);
    }
  }
220362
public void writeNullableByteArray( byte[] value )
    {
        if (value == null)
            write(NULL_VALUE);
        else
        {
            write(NOT_NULL_VALUE);
            writeInt(value.length);
            write(value);
        }
    }
468549
private List<Integer> asIntList(Object value) {
        int[] values = (int[]) value;
        List<Integer> list = new ArrayList<Integer>(values.length);
        for (int integer : values) {
            list.add(integer);
        }
        return list;
    }
728638
public static long fromBytes(byte[] value){
        if (value == null) return 0;
        long out = 0;
        int length = value.length;
        if (length > 8) length = 8;
        for (int i = 0; i < length; i++){
            out = (out << 8) + (value[i] & 0xff);
        }
        return out;
    }