Here you can find the source of intToTwoByte(int value, byte[] destination, int offset)
public static void intToTwoByte(int value, byte[] destination, int offset)
//package com.java2s; public class Main { private static final String ERR_VALUE_OOB = "Value out of bounds (%s)"; public static final int MAX_16BITS = 65535; public static byte[] intToTwoByte(int value) { if ((value < 0) || (value > MAX_16BITS)) throw new IllegalArgumentException(String.format(ERR_VALUE_OOB, value)); byte[] buf = new byte[2]; intToTwoByte(value, buf, 0);/*from w ww . ja va2 s . co m*/ return buf; } public static void intToTwoByte(int value, byte[] destination, int offset) { if ((value < 0) || (value > MAX_16BITS)) throw new IllegalArgumentException(String.format(ERR_VALUE_OOB, value)); destination[offset] = (byte) ((value & 0x0000FF00L) >> 8); destination[offset + 1] = (byte) ((value & 0x000000FFL)); } }