Java Long Number Create toLong(byte... b)

Here you can find the source of toLong(byte... b)

Description

to Long

License

GNU General Public License

Declaration

public static long toLong(byte... b) 

Method Source Code

//package com.java2s;
/**/*from w ww . jav  a  2 s.c om*/
 * License
 * 
 * Licensed under the GNU GPL v3
 * http://www.gnu.org/licenses/gpl.html
 * 
 */

public class Main {

    public static long toLong(byte... b) {
        long l = 0;
        int len = b.length;
        for (int i = 0; i < len && i < 8; i++) {
            l = (long) l << 8 | byte2UnsignInt(b[i]);
        }
        return l;
    }

    public static int byte2UnsignInt(byte b) {
        if (b >> 1 == b >>> 1)
            return b;
        else
            return 256 + b;
    }
}

Related

  1. toLong(boolean b)
  2. toLong(boolean... a)
  3. toLong(byte b)
  4. toLong(byte byte7, byte byte6, byte byte5, byte byte4, byte byte3, byte byte2, byte byte1, byte byte0)
  5. toLong(byte... b)
  6. toLong(byte[] arr)
  7. toLong(byte[] array, int offset)
  8. toLong(byte[] b)
  9. toLong(byte[] b)