美文网首页
java 正确的 byte[] 转long

java 正确的 byte[] 转long

作者: 搬砖中年人 | 来源:发表于2019-04-04 19:44 被阅读0次

/**

    * byte[] 转  long

    * 2016年9月30日

    */

    public static long bytesToLong(byte[] b) {

        long temp = 0;

        long res = 0;

        for (int i = 0; i < 8; i++) {

            temp = b[i] & 0xff;

            temp <<= 8*i;

            res |= temp;

        }

        return res;

    }

相关文章

网友评论

      本文标题:java 正确的 byte[] 转long

      本文链接:https://www.haomeiwen.com/subject/etmopqtx.html