Java Convert via ByteBuffer longFromBytes(byte[] array)

Here you can find the source of longFromBytes(byte[] array)

Description

long From Bytes

License

Open Source License

Declaration

public static long longFromBytes(byte[] array) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {
    public static long longFromBytes(byte[] array) {
        if (array.length != Long.BYTES) {
            throw new IllegalArgumentException(String.format("Invalid array lenght:%d", array.length));
        }//  w ww . j a v a  2 s.  co  m
        ByteBuffer bb = ByteBuffer.allocate(Long.BYTES);

        bb.put(array);

        bb.flip();

        return bb.getLong();
    }
}

Related

  1. intToBytes(int n)
  2. intToBytes(int tagId)
  3. intToBytesLE(int value)
  4. intToBytesWithLen(int x, int len)
  5. long2bytes(long num)
  6. longFromBytes(byte[] value)
  7. longTo4ByteArray(long n)
  8. longToByteArray(long l)
  9. longToByteArray(long value)