Java Long to Byte Array long2bytes(long v, int len)

Here you can find the source of long2bytes(long v, int len)

Description

longbytes

License

Apache License

Declaration

public static byte[] long2bytes(long v, int len) 

Method Source Code

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

public class Main {
    public static byte[] long2bytes(long v, int len) {
        byte[] b = new byte[len];
        for (int i = 7; i > 0 && i > (8 - len); i--) {
            b[i - (8 - len)] = (byte) (v >>> (56 - (i * 8)));
        }/*w ww . j  a  va  2s .com*/
        return b;
    }

    public static byte[] long2bytes(long v) {
        return long2bytes(v, 8);
    }
}

Related

  1. long2bytes(long longValue)
  2. long2bytes(long num)
  3. long2Bytes(long num)
  4. long2Bytes(long num)
  5. long2bytes(long v)
  6. long2bytes(long value)
  7. long2bytes(long value, byte[] bytes, int off)
  8. long2bytes(long value, byte[] bytes, int offset)
  9. long2bytes(long x)