Java Float Array Create toFloats(String floatArray)

Here you can find the source of toFloats(String floatArray)

Description

converts float values from string separated by " " (space) to an Array of floats

License

Open Source License

Parameter

Parameter Description
floatArray a parameter

Declaration

public static float[] toFloats(String floatArray) 

Method Source Code

//package com.java2s;
/**/*from w  ww . j a  v a  2 s .  com*/
 * <p>This class contains utility tools for all common or proprietary 
 * assembling classes.</p>
 *
 * <p>This source is free; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License and by nameing of the originally author</p>
 *
 * @author Markus Zimmermann <a href="http://www.die-seite.ch">http://www.die-seite.ch</a>
 * @version 3.1
 */

public class Main {
    /**
     * converts float values from string separated by
     * &quot; &quot; (space) to an Array of floats
     * @param floatArray
     * @return
     */
    public static float[] toFloats(String floatArray) {
        String[] s = floatArray.split(" ");
        float[] f = new float[s.length];
        for (int i = 0; i < f.length; i++) {
            f[i] = Float.parseFloat(s[i]);
        }
        return f;
    }
}

Related

  1. toFloats(byte[] value, int offset, int num)
  2. toFloats(double[] d)
  3. toFloats(final double[] array)
  4. toFloats(Float[] values)
  5. toFloats(Object[] extraArgs)
  6. toFloatValue(Object number)
  7. toFloatWithoutOverflow(double value)