Here you can find the source of tryParseInts(String[] in)
Parameter | Description |
---|---|
in | The input array. Must not be null |
public static int[] tryParseInts(String[] in)
//package com.java2s; //License from project: Creative Commons License public class Main { /**/* w ww.j av a2 s.c om*/ * Tries to parse an array of integers. * * Returns the parsed version of in or an empty array on any parse errors. * * @param in The input array. Must not be null * @return The result */ public static int[] tryParseInts(String[] in) { try { return parseInts(in); } catch (NumberFormatException e) { return new int[0]; } } /** * Parses an array of integers. * * @param in The input array. Must not be null * @return The result * @throws NumberFormatException If any element in in is not parsable */ public static int[] parseInts(String[] in) { int[] out = new int[in.length]; for (int i = 0; i < in.length; i++) { out[i] = Integer.parseInt(in[i]); } return out; } }