Convert int To Byte array - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Convert int To Byte array

Demo Code


//package com.java2s;

public class Main {
    public static byte[] intToByte(int value) {
        byte[] result = new byte[4];

        result[0] = (byte) (value >> 24);
        result[1] = (byte) (value >> 16);
        result[2] = (byte) (value >> 8);
        result[3] = (byte) (value); 
        return result;
    }/*from   w  ww  . ja v a2s .c  o  m*/
}

Related Tutorials