Java tutorial
//package com.java2s; public class Main { /** * <p>Extract long values from an array of strings into an array of int.</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 an long numeric value * @return an array of long */ static public long[] copyStringToLongArray(String[] src) { if (src == null) return null; int n = src.length; long[] dst = new long[n]; for (int j = 0; j < n; ++j) { long value = 0; try { value = Long.valueOf(src[j]).longValue(); } catch (NumberFormatException e) { } catch (NullPointerException e) { } dst[j] = value; } return dst; } }