Android Int to Byte Array Convert intToBytes(int number)

Here you can find the source of intToBytes(int number)

Description

int To Bytes

Declaration

public static byte[] intToBytes(int number) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] intToBytes(int number) {
        return new byte[] { (byte) ((number >> 24) & 0xFF),
                (byte) ((number >> 16) & 0xFF),
                (byte) ((number >> 8) & 0xFF), (byte) (number & 0xFF) };
    }//from   ww  w  .ja  va  2s  .c o m
}

Related

  1. IntToBytes(int value)
  2. intToBytes(byte[] bytes, int offset, int value)
  3. intToBytes(int number)
  4. toByteArray(int in)
  5. toByteArray(int in, int outSize)
  6. getTwoBytes(int i)
  7. getTwoBytes(int i, byte[] target, int pos)