Java Integer Create toInteger(String[] source)

Here you can find the source of toInteger(String[] source)

Description

to Integer

License

Open Source License

Declaration

public static Integer[] toInteger(String[] source) 

Method Source Code

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

public class Main {
    public static Integer[] toInteger(String[] source) {

        Integer[] result = new Integer[source.length];

        for (int i = 0; i < source.length; i++) {
            Integer v = Integer.getInteger(source[i]);
            if (v != null) {
                result[i] = v;/*from  w w  w .  j a va2s . co  m*/
            }
        }
        return result;
    }

    public static Integer[] toInteger(String source) {

        if (!isEmpty(source)) {
            return toInteger(source.split(","));
        } else {
            return null;
        }
    }

    public static int toInteger(String source, int value) {

        if (!isEmpty(source)) {
            try {
                return Integer.parseInt(source);
            } catch (Exception e) {
            }
        }
        return value;
    }

    public static boolean isEmpty(String str) {
        return (str == null || "".equals(str.trim()));
    }

    public static boolean equals(String str1, String str2) {
        if (str1 != null && str1 != null) {
            return str1.equals(str2);
        } else if (str1 == null && str2 == null) {
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. toInteger(String value, int _default)
  2. toInteger(String value, int defaultValue)
  3. toInteger(String value, int defaultValue)
  4. toInteger(String value, Integer defValue)
  5. toInteger(String[] s)
  6. toInteger(StringBuilder value)
  7. toIntegerArray(byte[] input, int offset, int len)
  8. toIntegerArray(double[] doubles)
  9. toIntegerArray(final int[] array)