Android Int to Byte Array Convert int2byteWithInvert(int input)

Here you can find the source of int2byteWithInvert(int input)

Description

intbyte With Invert

License

Open Source License

Declaration

public static byte[] int2byteWithInvert(int input) 

Method Source Code

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

public class Main {

    public static byte[] int2byteWithInvert(int input) {
        byte[] b = int2byte(input);
        int len = b.length;
        byte[] rtn = new byte[len];
        for (int i = 0; i < len; i++) {
            rtn[i] = b[len - 1 - i];/*from w w  w .  j  a  v  a 2 s.  co  m*/
        }
        return rtn;
    }

    public static byte[] int2byte(int input) {
        byte[] result = new byte[4];
        for (int i = 0;; i++) {
            if (i >= 4)
                return result;
            result[i] = (byte) (0xFF & input >> i * 8);
        }
    }
}

Related

  1. int2ByteArray(int value)
  2. int2ByteArray1(int value)
  3. int2ByteArray11(int value)
  4. int2ByteArray3(int value)
  5. int2byte(int input)
  6. int2bytesBE(int val, byte[] b, int off)
  7. int2bytesLE(int val, byte[] b, int off)
  8. int2hex(int i)
  9. intFitsIn(final int value)