Java Integer to Byte Array IntToBytes(int i)

Here you can find the source of IntToBytes(int i)

Description

Int To Bytes

License

Apache License

Declaration

public static byte[] IntToBytes(int i) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] IntToBytes(int i) {
        byte abyte0[] = new byte[2];
        abyte0[1] = (byte) (0xff & i);
        abyte0[0] = (byte) ((0xff00 & i) >> 8);
        return abyte0;
    }/* w ww .  j  a v  a2s. c  o m*/

    public static void IntToBytes(int i, byte abyte0[]) {
        abyte0[1] = (byte) (0xff & i);
        abyte0[0] = (byte) ((0xff00 & i) >> 8);
    }
}

Related

  1. intToBytes(int i)
  2. intToBytes(int i)
  3. intToBytes(int i)
  4. intToBytes(int i)
  5. intToBytes(int i)
  6. intToBytes(int i, byte[] data, int[] offset)
  7. intToBytes(int i_)
  8. intToBytes(int intValue)
  9. intToBytes(int ipInt)