Java Integer Array Create intArray(String data)

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

Description

int Array

License

Open Source License

Declaration

public static int[] intArray(String data) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int[] intArray(String data) {
        if (data == null || data.equals(""))
            return new int[0];
        String[] split = data.split(" ");
        int[] r = new int[split.length];
        for (int i = 0; i < r.length; i++) {
            try {
                r[i] = Integer.parseInt(split[i]);
            } catch (NumberFormatException e) {
                r[i] = 0;/*  w  ww.ja va 2s.  c om*/
            }
        }
        return r;
    }

    public static int parseInt(String s) {
        if (s != null) {
            try {
                return Integer.parseInt(s);
            } catch (NumberFormatException e) {
            } // Do nothing
        }
        return 0;
    }
}

Related

  1. intArray(double a, double b, double c)
  2. intArray(int len)
  3. intArray(Integer... values)
  4. intArrayConcat(int[] a, int[] b)
  5. intArrayContains(int val, int[] array)
  6. intArrayContains(int[] array, int key)
  7. intArrayEquals(int[] a1, int[] a2)