Java Integer to Byte Array intToBytesLittleEndian(final int i, final byte[] dest, final int offset)

Here you can find the source of intToBytesLittleEndian(final int i, final byte[] dest, final int offset)

Description

Single int into byte array

License

Open Source License

Parameter

Parameter Description
i data
dest output data
offset where to write to

Declaration

public static void intToBytesLittleEndian(final int i, final byte[] dest, final int offset) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*ww  w . ja  v a  2  s.c o m*/
     * Single <code>int</code> into byte array
     * @param i data
     * @param dest output data
     * @param offset where to write to
     */
    public static void intToBytesLittleEndian(final int i, final byte[] dest, final int offset) {
        dest[offset] = (byte) (i & 0xFF);
        dest[offset + 1] = (byte) ((i >> 8) & 0xFF);
        dest[offset + 2] = (byte) ((i >> 16) & 0xFF);
        dest[offset + 3] = (byte) ((i >> 24) & 0xFF);
    }
}

Related

  1. intToBytesBigend(int value)
  2. intToBytesBigEndian(int n)
  3. IntToBytesLE(final long val)
  4. intToBytesLE(int i, byte[] bytes, int off)
  5. intToBytesLE(int value, byte[] buffer, int offset, int length)
  6. intToBytesNoLeadZeroes(int val)
  7. intToBytesSizeOne(int integer)