Convert long byte[8] array - Android java.lang

Android examples for java.lang:array convert

Description

Convert long byte[8] array

Demo Code


//package com.java2s;

public class Main {

    public static byte[] longtoByte(long a) {
        byte[] b = new byte[8];
        b[0] = (byte) (a >> 56);
        b[1] = (byte) (a >> 48);
        b[2] = (byte) (a >> 40);
        b[3] = (byte) (a >> 32);

        b[4] = (byte) (a >> 24);
        b[5] = (byte) (a >> 16);
        b[6] = (byte) (a >> 8);
        b[7] = (byte) (a);

        return b;
    }//w  w w  . java2s.  c  o m
}

Related Tutorials