Java tutorial
//package com.java2s; public class Main { /** * <p>Extract short values from an array of strings into an array of short.</p> * * <p>Exceptions in the format of the string are trapped and 0 value(s) returned.</p> * * @param src an array of strings, each of which should be a short numeric value * @return an array of short */ static public short[] copyStringToShortArray(String[] src) { if (src == null) return null; int n = src.length; short[] dst = new short[n]; for (int j = 0; j < n; ++j) { short value = 0; try { value = Short.valueOf(src[j]).shortValue(); } catch (NumberFormatException e) { } catch (NullPointerException e) { } dst[j] = value; } return dst; } }