Here you can find the source of int2bytes(int value)
Parameter | Description |
---|---|
value | Integer to be transformed |
public static byte[] int2bytes(int value)
//package com.java2s; /*//from w w w .j av a2s .co m * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ public class Main { /** * Converts Integer value to Array of bytes * * @param value Integer to be transformed * @return Array of bytes representing Integer value */ public static byte[] int2bytes(int value) { return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) value }; } }