Java Integer From intFromBytes(byte[] bytes, int offset)

Here you can find the source of intFromBytes(byte[] bytes, int offset)

Description

int From Bytes

License

Open Source License

Declaration

public static int intFromBytes(byte[] bytes, int offset) 

Method Source Code

//package com.java2s;
/*//from w w  w  . j a v a 2 s  .c  om
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2013 Ausenco Engineering Canada Inc.
 *
 * This program 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.
 *
 * This program 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.
 */

public class Main {
    public static int intFromBytes(byte[] bytes, int offset) {
        int ret = 0;
        ret |= (bytes[offset + 0] & 0xFF) << 24;
        ret |= (bytes[offset + 1] & 0xFF) << 16;
        ret |= (bytes[offset + 2] & 0xFF) << 8;
        ret |= bytes[offset + 3] & 0xFF;
        return ret;
    }
}

Related

  1. intFrombytes(byte[] b, int pos)
  2. intFromBytes(byte[] buffer)
  3. intFromBytes(byte[] buffer, int offset)
  4. intFromBytes(byte[] bytes)
  5. intFromBytes(byte[] bytes)
  6. intFromByteWithoutStupidJavaSignExtension(byte val)
  7. intFromHex(String hex, boolean signed)
  8. intFromJSON(String[] json, int pos)
  9. intFromLex(byte[] bytes)