Android Long to Byte Array Convert long2bytes(long val)

Here you can find the source of long2bytes(long val)

Description

longbytes

Declaration

public static byte[] long2bytes(long val) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] long2bytes(long val) {
        byte[] data = new byte[8];

        data[0] = (byte) (val & 0xFF);
        data[1] = (byte) (val >> 8 & 0xFF);
        data[2] = (byte) (val >> 16 & 0xFF);
        data[3] = (byte) (val >> 24 & 0xFF);
        data[4] = (byte) (val >> 32 & 0xFF);
        data[5] = (byte) (val >> 40 & 0xFF);
        data[6] = (byte) (val >> 48 & 0xFF);
        data[7] = (byte) (val >> 56 & 0xFF);

        return data;
    }//from   ww w .  java 2  s. c o  m
}

Related

  1. getByteArrayByLong(long value, int n, boolean isLH)
  2. getBytes(long data)
  3. uint32ToByteArrayLE(long value, byte[] output, int offset)
  4. uint64ToByteArrayLE(long value, byte[] output, int offset)
  5. long2byteArray(final long number, final int length, final boolean swapHalfWord)
  6. convertToByteArray(long l)
  7. long2bytes(long num)
  8. toBytes(long longValue)
  9. ulong2bytes(long value)