Java Utililty Methods Array Convert to

List of utility methods to do Array Convert to

Description

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

Method

StringconvertArrayToCSVString(String[] s)
convert Array To CSV String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length; i++) {
    if (i > 0) {
        sb.append("|");
    sb.append(s[i]);
return sb.toString();
...
int[]convertArrayToInteger(String[] input)
convert Array To Integer
int[] result = new int[input.length];
for (int i = 0; i < input.length; i++) {
    result[i] = Integer.parseInt(input[i].trim());
return result;
StringconvertArrayToLine(String[] cols)
Create a single line of CSV file.
StringBuilder buf = new StringBuilder();
for (int i = 0; i < cols.length; i++) {
    if (i > 0) {
        buf.append(",");
    if (cols[i].length() > 0) {
        buf.append("\"");
        buf.append(cols[i].replace("\"", "\"\""));
...
intconvertArrayType(String type)
convert Array Type
switch (type) {
case "boolean[]": 
    return PG_TYPE_BOOLARRAY;
case "byte[]": 
case "short[]": 
    return PG_TYPE_INT2ARRAY;
case "integer[]": 
    return PG_TYPE_INT4ARRAY;
...
StringconvertArrayTypeName(final String typeName)
Converts an internal Java array type name ([Lblabla) to the a the format used by the expression matcher (blabla[])
int index = typeName.lastIndexOf('[');
if (index != -1) {
    StringBuffer arrayType = new StringBuffer();
    if (typeName.endsWith("I")) {
        arrayType.append("int");
    } else if (typeName.endsWith("J")) {
        arrayType.append("long");
    } else if (typeName.endsWith("S")) {
...
ObjectconvertArrayValue(Object value, Class type)
convert Array Value
if (type.equals(String.class)) {
    return value.toString();
} else if (type.equals(Long.class)) {
    return ((Number) value).longValue();
} else if (type.equals(Double.class)) {
    return ((Number) value).doubleValue();
} else {
    return value;
...
double[]toDoubleArray(byte[] data)
Convenience method for creating a double array from a byte array.
double[] result = new double[data.length / 8];
byte[] tmp = new byte[8];
for (int i = 0; i < result.length; i++) {
    System.arraycopy(data, i * 8, tmp, 0, 8);
    result[i] = toDouble(tmp);
return result;
double[]toDoubleArray(Double[] list)
to Double Array
double[] array = new double[list.length];
for (int i = 0; i < array.length; i++)
    array[i] = list[i];
return array;
double[]toDoubleArray(final int[] intArray)
to Double Array
double[] array = null;
if (intArray != null) {
    array = new double[intArray.length];
    for (int i = 0; i < intArray.length; i++) {
        array[i] = (double) intArray[i];
return array;
...
float[]toFloatArray(final double[] doubles)
to Float Array
final float[] floats = new float[doubles.length];
for (int i = 0; i < doubles.length; i++) {
    floats[i] = (float) doubles[i];
return floats;