Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static long bytes2long(byte[] bytes, int offset) {
        if (bytes == null || bytes.length < (offset + 7)) {
            throw new IllegalArgumentException();
        }
        long l = 0l;
        l = bytes[offset] & 0xFF;
        l = (l << 8) | (bytes[offset + 1] & 0xff);
        l = (l << 8) | (bytes[offset + 2] & 0xff);
        l = (l << 8) | (bytes[offset + 3] & 0xff);
        l = (l << 8) | (bytes[offset + 4] & 0xff);
        l = (l << 8) | (bytes[offset + 5] & 0xff);
        l = (l << 8) | (bytes[offset + 6] & 0xff);
        l = (l << 8) | (bytes[offset + 7] & 0xff);
        return l;
    }
}