Here you can find the source of toShortArray(final byte[] array)
public static short[] toShortArray(final byte[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static short[] toShortArray(final byte[] array) { return toShortArray(array, 0, array.length); }/* w ww. ja v a 2 s.c o m*/ public static short[] toShortArray(final byte[] array, final int off, final int len) { return toShortArray(array, off, len, new short[len], 0); } public static short[] toShortArray(final byte[] from, final int fromOff, final int len, final short[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = from[i]; } return to; } public static short[] toShortArray(final char[] array) { return toShortArray(array, 0, array.length); } public static short[] toShortArray(final char[] array, final int off, final int len) { return toShortArray(array, off, len, new short[len], 0); } public static short[] toShortArray(final char[] from, final int fromOff, final int len, final short[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (short) from[i]; } return to; } public static short[] toShortArray(final int[] array) { return toShortArray(array, 0, array.length); } public static short[] toShortArray(final int[] array, final int off, final int len) { return toShortArray(array, off, len, new short[len], 0); } public static short[] toShortArray(final int[] from, final int fromOff, final int len, final short[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (short) from[i]; } return to; } public static short[] toShortArray(final long[] array) { return toShortArray(array, 0, array.length); } public static short[] toShortArray(final long[] array, final int off, final int len) { return toShortArray(array, off, len, new short[len], 0); } public static short[] toShortArray(final long[] from, final int fromOff, final int len, final short[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (short) from[i]; } return to; } public static short[] toShortArray(final float[] array) { return toShortArray(array, 0, array.length); } public static short[] toShortArray(final float[] array, final int off, final int len) { return toShortArray(array, off, len, new short[len], 0); } public static short[] toShortArray(final float[] from, final int fromOff, final int len, final short[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (short) from[i]; } return to; } public static short[] toShortArray(final double[] array) { return toShortArray(array, 0, array.length); } public static short[] toShortArray(final double[] array, final int off, final int len) { return toShortArray(array, off, len, new short[len], 0); } public static short[] toShortArray(final double[] from, final int fromOff, final int len, final short[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (short) from[i]; } return to; } }