Android Big Endian Convert setLittleIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)

Here you can find the source of setLittleIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)

Description

put number in array (big endian way)

Parameter

Parameter Description
toPutIn - the array to put in
startidx - start index of the num
theNumber - the number
len - the number size in bytes.

Declaration

public static void setLittleIndianInBytesArray(byte[] toPutIn,
        int startidx, long theNumber, int len) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w  ww .j  av  a  2  s  . c o  m
     * put number in array (big endian way)
     * @param toPutIn - the array to put in
     * @param startidx - start index of the num
     * @param theNumber - the number
     * @param len - the number size in bytes.
     */
    public static void setLittleIndianInBytesArray(byte[] toPutIn,
            int startidx, long theNumber, int len) {
        for (int i = 0; i < len; i++) {
            toPutIn[i + startidx] = (byte) (theNumber % 256);
            theNumber /= 256;
        }
    }
}

Related

  1. getShort(byte[] data, int i, boolean bigEndian)
  2. switchEndian(int i)
  3. switchEndian(long l)
  4. switchEndian(short i)
  5. setBigIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)