Here you can find the source of intToByte2Array(int x)
public static byte[] intToByte2Array(int x)
//package com.java2s; /*//from w ww. java 2 s. com * AlbatrossUtils.java * * Copyright (C) 2008 Mark Fenton * * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static byte[] intToByte2Array(int x) { byte[] buf = new byte[2]; buf[1] = (byte) ((x & 0x0000ff00) >>> 8); buf[0] = (byte) ((x & 0x000000ff)); return buf; } }