Java Integer Array Create intArrayFromString(final String data)

Here you can find the source of intArrayFromString(final String data)

Description

int Array From String

License

Open Source License

Declaration

private static int[] intArrayFromString(final String data) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String CONFIG_EMPTY = "NONE";
    private static final String CONFIG_SEPARATOR_ARRAY = ";";

    private static int[] intArrayFromString(final String data) {
        final int[] result;
        if (data.equals(CONFIG_EMPTY)) {
            result = null;/*  w w w  . j  a  va  2  s  .  co m*/
        } else {
            final String[] split = data.split(CONFIG_SEPARATOR_ARRAY);
            result = new int[split.length];
            for (int i = 0; i < split.length; i++) {
                result[i] = Integer.parseInt(split[i].trim());
            }
        }
        return result;
    }
}

Related

  1. intArray(String data)
  2. intArrayConcat(int[] a, int[] b)
  3. intArrayContains(int val, int[] array)
  4. intArrayContains(int[] array, int key)
  5. intArrayEquals(int[] a1, int[] a2)
  6. intArrayFromString(String record)
  7. intArrayMin(int[] arr)
  8. intArraysAreEqual(int array1[], int array2[])
  9. intArraySet(int arr[], int val)