Here you can find the source of tryParseFloats(String[] in)
Parameter | Description |
---|---|
in | The input array. Must not be null |
public static float[] tryParseFloats(String[] in)
//package com.java2s; //License from project: Creative Commons License public class Main { /**/*from w w w .j ava 2 s .co m*/ * Tries to parse an array of floats. * * 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 float[] tryParseFloats(String[] in) { try { return parseFloats(in); } catch (NumberFormatException e) { return new float[0]; } } /** * Parses an array of floats. * * @param in The input array. Must not be null * @return The result * @throws NumberFormatException If any element in in is not parsable */ public static float[] parseFloats(String[] in) { float[] out = new float[in.length]; for (int i = 0; i < in.length; i++) { out[i] = Float.parseFloat(in[i]); } return out; } }