Java Integer to Byte int2byte(byte[] output, int[] input, int len)

Here you can find the source of int2byte(byte[] output, int[] input, int len)

Description

Encodes input (int) into output (bytes).

License

Open Source License

Declaration

final static void int2byte(byte[] output, int[] input, int len) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*  ww w.j av a2s  .co m*/
     * Encodes input (int) into output (bytes). 
     * Assumes len is a multiple of 4.
     */
    final static void int2byte(byte[] output, int[] input, int len) {
        int i = 0;
        if ((len % 4) != 0) {
            println("Error: int2byte(..., len), len not multiple of 4");
            println("Error: result will probably be wrong");
        }
        for (int j = 0; j < len; j += 4) {
            output[j + 0] = (byte) (input[i] & 0xff);
            output[j + 1] = (byte) ((input[i] >>> 8) & 0xff);
            output[j + 2] = (byte) ((input[i] >>> 16) & 0xff);
            output[j + 3] = (byte) ((input[i] >>> 24) & 0xff);
            i++;
        }
    }

    final static void println(String s) {
        System.out.println(s);
    }
}

Related

  1. asByte(int a)
  2. int2bcdByte(int hRadix10, int lRadix10)
  3. int2bin(byte[] out, int offset, int i)
  4. int2byte(final int i)
  5. int2byte(int i)
  6. int2Byte(int intValue)
  7. int2byte(int ival, byte b[], int offset)