Convert byte array To Long by shifting left - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Convert byte array To Long by shifting left

Demo Code


//package com.java2s;

public class Main {
    public static long bytesToLong(byte[] b) {
        long result = 0;
        for (int i = 0; i < 8; i++) {
            result <<= 8;/*  w w  w .  java2  s  . co  m*/
            result |= (b[i] & 0xFF);
        }
        return result;
    }
}

Related Tutorials