Android Int to Byte Array Convert int2bytes(int val)

Here you can find the source of int2bytes(int val)

Description

intbytes

Declaration

public static byte[] int2bytes(int val) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] int2bytes(int val) {
        byte[] data = new byte[4];

        data[0] = (byte) (val & 0xFF);
        data[1] = (byte) (val >> 8 & 0xFF);
        data[2] = (byte) (val >> 16 & 0xFF);
        data[3] = (byte) (val >> 24 & 0xFF);

        return data;
    }//from  w  w  w  . j  a va  2 s  . c o  m
}

Related

  1. toBytes(int value)
  2. toBytes(int value, byte[] dest, int destPos)
  3. getBytes(int data)
  4. putInt(byte[] bb, int x, int index)
  5. putInt(byte[] bb, int x, int index)
  6. IntToByte(int i)
  7. uInt16ToBytesBI(int value)
  8. uInt16ToBytesBI(int value, byte[] buffer, int startIndex)
  9. uInt16ToBytesLI(int value)