Java Integer to Byte int2byteArray(int k, byte b[], int off)

Here you can find the source of int2byteArray(int k, byte b[], int off)

Description

intbyte Array

License

Open Source License

Declaration

public static void int2byteArray(int k, byte b[], int off) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public final static int INT_BYTES = 4;

    public static void int2byteArray(int k, byte b[], int off) {
        int j;/* ww  w.  j  av  a 2 s .  c  om*/

        j = b.length;
        if (b == null || j <= off) {
            return;
        }

        j -= off;
        if (j > INT_BYTES) {
            j = INT_BYTES;
        }

        switch (j) {
        case 4:
            b[off + 3] = (byte) ((k >> 24) & 0x0ff);
        case 3:
            b[off + 2] = (byte) ((k >> 16) & 0x0ff);
        case 2:
            b[off + 1] = (byte) ((k >> 8) & 0x0ff);
        case 1:
            b[off] = (byte) (k & 0x0ff);
        }
    }
}

Related

  1. int2Byte(int intValue)
  2. int2byte(int ival, byte b[], int offset)
  3. int2byte(int value)
  4. int2byte(int[] ia)
  5. int2ByteArray(int i)
  6. int2ByteArray(int value)
  7. int2byteArray(int[] i)
  8. int2ByteArrayLength4(int theInt)
  9. int2ToByteArray(int value)