convert Int To Byte - Android java.lang

Android examples for java.lang:Byte

Description

convert Int To Byte

Demo Code


//package com.java2s;
import java.math.BigInteger;

public class Main {
     static byte convertIntToByte2(int x) {
        final byte[] test = BigInteger.valueOf(x).toByteArray();
        if (test.length > 0) {
            return test[0];
        }/*from ww  w.ja va2  s. c o m*/

        return 0x00;
    }
}

Related Tutorials