Java Integer to Byte intToByte(int number, int byteLength)

Here you can find the source of intToByte(int number, int byteLength)

Description

int To Byte

License

Apache License

Declaration

public static byte[] intToByte(int number, int byteLength) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] intToByte(int number, int byteLength) {
        byte[] bLocalArr = new byte[byteLength];
        for (int i = 0; (i < 4) && (i < byteLength); i++) {
            bLocalArr[i] = (byte) (number >> 8 * i & 0xFF);
        }/*  w ww. j av  a2s. com*/
        return bLocalArr;
    }

    public static byte[] intToByte(int number) {
        int byteLength = 4;
        byte[] bLocalArr = new byte[byteLength];
        for (int i = 0; (i < 4) && (i < byteLength); i++) {
            bLocalArr[i] = (byte) (number >> 8 * i & 0xFF);
        }
        return bLocalArr;
    }
}

Related

  1. intToByte(int i_Value)
  2. intToByte(int myInt)
  3. intToByte(int num)
  4. intToByte(int number)
  5. intToByte(int number)
  6. intToByte(int v, byte[] dest)
  7. intToByte(int value)
  8. intToByte(int value)
  9. intToByte(int[] values)