Java Integer Create toInts(String intArray)

Here you can find the source of toInts(String intArray)

Description

converts int values from string separated by " " (space) to an Array of integer

License

Open Source License

Parameter

Parameter Description
intArray a parameter

Declaration

public static int[] toInts(String intArray) 

Method Source Code

//package com.java2s;
/**/*from   www. j av  a  2 s .c  om*/
 * <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 int values from string separated by
     * &quot; &quot; (space) to an Array of integer
     * @param intArray
     * @return
     */
    public static int[] toInts(String intArray) {
        String[] s = intArray.split(" ");
        int[] ia = new int[s.length];
        for (int i = 0; i < ia.length; i++) {
            ia[i] = Integer.parseInt(s[i]);
        }
        return ia;
    }
}

Related

  1. toInts(byte[] value, int offset, int num)
  2. toInts(double[] arr)
  3. toInts(int val)
  4. toInts(Integer[] values)
  5. toInts(long[] array)
  6. toInts(String[] values)
  7. toIntsFromUBytes(byte[] byteArray)
  8. toIntStr(String floatStr)
  9. toIntString(Integer integer)