Java Short Number Array Create toShorts(byte[] readBuffer, int o, int l)

Here you can find the source of toShorts(byte[] readBuffer, int o, int l)

Description

to Shorts

License

Open Source License

Declaration

public static short[] toShorts(byte[] readBuffer, int o, int l) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static short[] toShorts(byte[] readBuffer, int o, int l) {
        short[] v = new short[l / 2];
        for (int i = 0; i < v.length; i++)
            v[i] = toShort(readBuffer, o + i * 2);
        return v;
    }//from  w w  w .j  a  va  2 s. co m

    public static short toShort(byte[] readBuffer, int o) {
        return (short) (((readBuffer[o + 0] & 255) << 8) + ((readBuffer[o + 1] & 255) << 0));
    }

    public static short toShort(byte[] readBuffer) {
        return toShort(readBuffer, 0);
    }
}

Related

  1. toShortArray(boolean[] array)
  2. toShorts(byte[] array, int offset, int length)
  3. toShorts(byte[] bytes)
  4. toShorts(byte[] value, int offset, int num)
  5. toShorts(Short[] values)