Java Byte Array Create toBytes(long size)

Here you can find the source of toBytes(long size)

Description

to Bytes

License

Open Source License

Declaration

public static byte[] toBytes(long size) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] toBytes(long size) {
        byte[] bytes = new byte[8];
        bytes[0] = (byte) ((size >> 56) & 0xff);
        bytes[1] = (byte) ((size >> 48) & 0xff);
        bytes[2] = (byte) ((size >> 40) & 0xff);
        bytes[3] = (byte) ((size >> 32) & 0xff);
        bytes[4] = (byte) ((size >> 24) & 0xff);
        bytes[5] = (byte) ((size >> 16) & 0xff);
        bytes[6] = (byte) ((size >> 8) & 0xff);
        bytes[7] = (byte) ((size >> 0) & 0xff);
        return bytes;
    }/*from   w w w.  jav  a2 s  . com*/
}

Related

  1. toBytes(long l)
  2. toBytes(long l, byte[] bytes, int offset, int limit)
  3. toBytes(long lp)
  4. toBytes(long n)
  5. toBytes(long number)
  6. toBytes(long v, byte[] writeBuffer, int o)
  7. toBytes(long val)
  8. toBytes(long value)
  9. toBytes(long value)