Here you can find the source of intToByteArrayLE(int v)
Parameter | Description |
---|---|
v | the integer |
public static byte[] intToByteArrayLE(int v)
//package com.java2s; /*//from w w w. j av a2 s . c o m * This file is part of Gjokii. * * Gjokii is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Gjokii 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Gjokii. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Convert an integer to byte array using Little Endian representation * * @param v * the integer * @return the byte array representing the integer */ public static byte[] intToByteArrayLE(int v) { return new byte[] { (byte) ((v & 0x000000FF)), (byte) ((v & 0x0000FF00) >> 8), (byte) ((v & 0x00FF0000) >> 16), (byte) ((v & 0xFF000000) >> 24) }; } }