List of utility methods to do Integer Create
int | toInteger(String value, int defaultValue) Parse a string to an integer value, using a given default on fail int ret = defaultValue; try { ret = Integer.parseInt(value); } catch (NumberFormatException e) { return ret; |
int | toInteger(String value, int defaultValue) to Integer int valueAsInt = 0; try { valueAsInt = Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; return valueAsInt; |
Integer | toInteger(String value, Integer defValue) Parse the given String value as an integer. try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defValue; |
Integer | toInteger(String[] s) to Integer if (s == null || s.length == 0) return null; Integer result = null; try { result = Integer.valueOf(s[0]); } catch (NumberFormatException e) { return result; ... |
Integer[] | toInteger(String[] source) to Integer 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; return result; ... |
Integer | toInteger(StringBuilder value) to Integer return Integer.parseInt(value.toString());
|
int[] | toIntegerArray(byte[] input, int offset, int len) to Integer Array assert len % 4 == 0 : "Must be a multiple of 4 bytes"; int[] result = new int[len / 4]; toIntegerArray(input, offset, len, result, 0); return result; |
int[] | toIntegerArray(double[] doubles) Converts an array of double values into an array of integer values by casting them. int[] ints = new int[doubles.length]; for (int i = 0; i < doubles.length; i++) { ints[i] = (int) doubles[i]; return ints; |
Integer[] | toIntegerArray(final int[] array) Converts the primitive int array into an Integer wrapper object array. final Integer[] integerArray = new Integer[array == null ? 0 : array.length]; if (array != null) { for (int index = 0; index < array.length; index++) { integerArray[index] = array[index]; return integerArray; |
Integer[] | toIntegerArray(final int[] ints) Produces an array of Integer objects from an int[] .
final Integer[] result = new Integer[ints.length]; for (int i = 0; i < ints.length; i++) { result[i] = Integer.valueOf(ints[i]); return result; |