Java ByteBuffer to Int Array getIntBE(ByteBuffer b, int start, int end)

Here you can find the source of getIntBE(ByteBuffer b, int start, int end)

Description

get Int BE

License

Open Source License

Declaration

public static int getIntBE(ByteBuffer b, int start, int end) 

Method Source Code

//package com.java2s;
/*/*from   w  w w  .j  a  v a 2  s.  c o m*/
 * Entagged Audio Tag library
 * Copyright (c) 2003-2005 Rapha?l Slinckx <raphael@slinckx.net>
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *  
 * 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.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

import java.nio.ByteBuffer;

public class Main {
    public static int getIntBE(byte[] b, int start, int end) {
        return (int) getLongBE(ByteBuffer.wrap(b), start, end);
    }

    public static int getIntBE(ByteBuffer b, int start, int end) {
        return (int) getLongBE(b, start, end);
    }

    public static long getLongBE(ByteBuffer b, int start, int end) {
        int number = 0;
        for (int i = 0; i < (end - start + 1); i++) {
            number += ((b.get(end - i) & 0xFF) << i * 8);
        }

        return number;
    }
}

Related

  1. getInt(ByteBuffer byteBuffer)
  2. getInt(ByteBuffer intCalculator, byte[] bytes)
  3. getInt8(ByteBuffer input)
  4. getIntArray(ByteBuffer buffer, int size)
  5. getIntArray(ByteBuffer data, int offset, int length)
  6. getIntBE(final ByteBuffer b, final int start, final int end)
  7. getIntByteBuffer(int id)
  8. getIntegerFromBuffer(ByteBuffer buffer, int offset, int size)
  9. getIntFromBack(ByteBuffer bb)