Java Utililty Methods Array From

List of utility methods to do Array From

Description

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

Method

byte[]arrayFromArrayWithLength(final byte[] array, final int length)
array From Array With Length
final byte[] output = new byte[length];
for (int j = 0; j < length; j++) {
    output[j] = array[(j % array.length)];
return output;
double[]arrayFromIndex(double[][] values, int index)
array From Index
double[] array = new double[values.length];
for (int i = 0; i < values.length; i++) {
    array[i] = values[i][index];
return array;
String[]arrayFromList(String aList)
Function arrayFromList Given a comma seperated list, possibly within brackets this function will return all the comma seperated items as an array from strings
String aS1 = aList.replaceAll("[\\s\"\'\\]\\[]+", "");
String[] aV = aS1.split(",");
return aV;
String[]arrayFromString(String fromString)
array From String
if (fromString == null) {
    return null;
return fromString.split(";");
String[]arrayFromString(String s)
array From String
if (s == null)
    return new String[] {};
if (!s.startsWith("[") || !s.endsWith("]"))
    throw new IllegalArgumentException();
if (s.length() == 2)
    return new String[] {};
return s.substring(1, s.length() - 1).split(" *, *");
String[]arrayFromString(String str)
array From String
if ((str != null) && (str.length() > 0)) {
    return str.split("[ ,;]");
} else {
    return null;
Boolean[]toArray(boolean[] array)
to Array
Boolean[] newArray = new Boolean[array.length];
for (int i = 0; i < array.length; i++) {
    newArray[i] = Boolean.valueOf(array[i]);
return newArray;
boolean[]toArray(CharSequence input)
Translates a String of zero ('0') and one ('1') characters to an array of boolean.
int len = input.length();
boolean[] bools = new boolean[len];
for (int i = 0; i < len; i++) {
    bools[i] = (input.charAt(i) == '1');
return bools;
Class[]toArray(Class interfaceClass)
to Array
return new Class[] { interfaceClass };
double[]toArray(Double[] array)
to Array
if (array == null) {
    return null;
double[] data = new double[array.length];
for (int i = 0; i < array.length; i++) {
    double val = (array[i] == null) ? 0 : array[i].intValue();
    data[i] = val;
return data;