Java Long Number Create toLong(byte[] bytes)

Here you can find the source of toLong(byte[] bytes)

Description

to Long

License

Open Source License

Parameter

Parameter Description
bytes a parameter

Declaration

public static final long toLong(byte[] bytes) 

Method Source Code

//package com.java2s;
/**//from  ww  w.  j ava2s .  co  m
 * This file is part of tera-api.
 * 
 * tera-api is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * tera-api is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with tera-api.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * @param bytes
     * @return
     */
    public static final long toLong(byte[] bytes) {
        long result = 0;
        result += (bytes[3] & 0xFF);
        result += ((bytes[2] & 0xFF) << 8);
        result += ((bytes[1] & 0xFF) << 16);
        result += (bytes[0] << 24);
        return result & 0xFFFFFFFFl;
    }
}

Related

  1. toLong(byte[] buf)
  2. toLong(byte[] buf, int off)
  3. toLong(byte[] buf, int pos)
  4. toLong(byte[] byteArray)
  5. toLong(byte[] bytes)
  6. toLong(byte[] bytes)
  7. toLong(byte[] bytes)
  8. toLong(byte[] bytes)
  9. toLong(byte[] bytes)