Java Utililty Methods Array Create

List of utility methods to do Array Create

Description

The list of methods to do Array Create are organized into topic(s).

Method

String[]toArray(String str)
to Array
return str.equals("") ? new String[0] : str.split(LIST_SEPARATOR);
int[]toArray(String str)
Parses a formated string and returns an array.
if (str == null && !str.matches("\\(.*|\\{.*|\\[.*")) {
    System.err.println("ERROR: Format should match: {n,n} (n,n) or [n,n]");
    return null;
String[] tmp = str.split(",");
int size = tmp.length;
if ((str = str.replaceAll("\\s", "")).length() < 2 * size + 1) {
    System.err.println("ERROR: Parsed length is too short: " + str.length());
...
String[]toArray(String str, String split)
to Array
if (isNull(str)) {
    return null;
if (isNull(split)) {
    split = ",";
return str.split(split);
String[]toArray(String string)
to Array
return string.split(",");
String[]toArray(String text)
Convert the given text to String array.
if (text == null)
    return null;
text = text.trim().replaceAll("\\[(.*)\\]", "$1").trim();
String regex = " *, *";
String[] array = text.split(regex);
return array;
T[]toArray(T... items)
to Array
return items;
T[]toArray(T... items)
Small syntactical helper.
return items;
StringtoArrayClass(String className)
Returns the array class name for the given class name.
return "[L" + className + ";";
double[]toArrayDouble(final int[] array)
Convert an array of int to an array of double
if (array == null)
    return null;
final double[] result = new double[array.length];
for (int i = 0; i < result.length; i++)
    result[i] = array[i];
return result;
String[]toArrayElement(String s)
Takes a String s and returns a new String[1] with s as the only element.
return (s == null || s.length() == 0) ? new String[0] : new String[] { s };