Java Convert via ByteBuffer toLongArray(byte[] b)

Here you can find the source of toLongArray(byte[] b)

Description

to Long Array

License

Open Source License

Declaration

public static long[] toLongArray(byte[] b) 

Method Source Code

//package com.java2s;
/**/*  w  w w .  j  a va  2 s  .c  om*/
 * @(#)ByteUtils.java, 2013-2-24.
 * 
 * Copyright 2013 Netease, Inc. All rights reserved.
 * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.nio.ByteBuffer;

public class Main {

    public static long[] toLongArray(byte[] b) {
        ByteBuffer bb = ByteBuffer.wrap(b);

        int length = bb.getInt();
        if (length == -1) {
            return null;
        }

        long[] la = new long[length];
        for (int i = 0; i < length; i++) {
            la[i] = bb.getLong();
        }

        return la;
    }
}

Related

  1. toLittleEndian(int value)
  2. toLMBCS(final String value)
  3. toLong(byte data[])
  4. toLong(byte[] array)
  5. toLong(byte[] bytes)
  6. ToLongArray(byte[] data)
  7. toLongArray(byte[] ids)
  8. toMappedBuffer(File file)
  9. toMappedBuffer(File file)