Java Unsigned Int Create toUnsignedIntBigEndien(byte[] bytes)

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

Description

to Unsigned Int Big Endien

License

Open Source License

Declaration

public static int toUnsignedIntBigEndien(byte[] bytes) 

Method Source Code

//package com.java2s;
/**/*  ww  w .j a  va 2  s.  c  o  m*/
 * A few conversion/convenience utility methods for dealing with binary data
 *
 * <pre>
 * (C) Copyright 2015 Christopher Piggott (cpiggott@gmail.com)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library 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
 * Lesser General Public License for more details.
 * </pre>
 */

public class Main {
    public static int toUnsignedIntBigEndien(byte[] bytes) {
        int v = 0;
        for (int i = 0; i < bytes.length; i++) {
            v = (v << (8 * i)) + (bytes[i] & 0xFF);
        }
        return v;
    }
}

Related

  1. toUnsignedInt(long value)
  2. toUnsignedInt(String string)
  3. toUnsignedInt16(byte[] bytes)
  4. toUnsignedInt32LittleEndian(byte[] bytes)
  5. toUnsignedIntArray(byte[] val)