Java Array Convert to arrayToInt(final byte[] array, final int start)

Here you can find the source of arrayToInt(final byte[] array, final int start)

Description

Convert the contents of the specified array to an int, starting at an offset of start.

License

Open Source License

Parameter

Parameter Description
array a parameter
start a parameter

Return

int

Declaration


public static int arrayToInt(final byte[] array, final int start) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

public class Main {
    private static final int MASK_FF = 0xff;

    /***********************************************************************************************
     * Convert the contents of the specified array to an <code><b>int</b></code>,
     * starting at an offset of <code>start</code>.
     *//from  ww  w  .ja  v  a2s .co m
     * @param array
     * @param start
     *
     * @return int
     */

    public static int arrayToInt(final byte[] array, final int start) {
        final int lowbits;
        final int highbits;

        lowbits = array[start] & MASK_FF;
        highbits = array[start + 1] & MASK_FF;

        return ((highbits << 8 | lowbits));
    }
}

Related

  1. arrayOfValuesToLookForIsEmpty()
  2. arrayToCamelCase(String[] nameArray, int start, int end)
  3. arrayToCSL(String[] vals)
  4. arrayToDouble(final byte[] array, final int start)
  5. arrayToHTMLString(Object[] objectArray, int indent)
  6. arrayToJava(double[] v, int off, int len, String name)
  7. arrayToJson(int[] x)
  8. arrayToLine(Object[] source)
  9. arrayToLines(String[] lines)