Here you can find the source of longToIntBytes(long a)
Parameter | Description |
---|---|
a | long integer |
public static byte[] longToIntBytes(long a)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww.j a va 2 s .com*/ * Convert a long value to a 4-byte array. * @param a long integer * @return byte[4] array */ public static byte[] longToIntBytes(long a) { byte[] returnByteArray = new byte[4]; //int is 4 bytes returnByteArray[0] = (byte) ((a & 0xff000000) >> 24); returnByteArray[1] = (byte) ((a & 0x00ff0000) >> 16); returnByteArray[2] = (byte) ((a & 0x0000ff00) >> 8); returnByteArray[3] = (byte) ((a & 0x000000ff)); return returnByteArray; } }