Here you can find the source of toShortArray(Object[] array)
public static short[] toShortArray(Object[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static short[] toShortArray(Object[] array) { if (array == null) return null; short[] ret = new short[array.length]; for (int i = 0; i < array.length; i++) ret[i] = parseShort(array[i]); return ret; }// w w w. j a va 2 s . co m public static short parseShort(Object o) { if (o == null) return 0; if (o instanceof Number) return ((Number) o).shortValue(); return parseShort(o.toString()); } public static short parseShort(String str) { try { if (str == null) return 0; str = str.trim(); if (str.startsWith("+")) str = str.substring(1); int o = str.indexOf('.'); if (o >= 0) str = str.substring(0, o); return Short.parseShort(str); } catch (NumberFormatException e) { return 0; } } public static String toString(short[] arr) { StringBuffer sb = new StringBuffer("["); for (int i = 0; i < arr.length; i++) { if (i > 0) sb.append(", "); sb.append(arr[i]); } sb.append("]"); return sb.toString(); } }