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

int[]toArray(int time)
to Array
return new int[] { (int) Math.floor(time / 3600),
        (int) Math.floor((time / 60) - (Math.floor(time / 3600) * 60)), (int) Math.floor(time % 60) };
byte[]toArray(int value)
to Array
return new byte[] { (byte) value, (byte) (value >> 8), (byte) (value >> 16), (byte) (value >> 24) };
voidtoArray(int value, byte b[], int offset)
to Array
b[offset] = (byte) (value & 0xff);
b[offset + 1] = (byte) ((value & 0xff00) >> 8);
b[offset + 2] = (byte) ((value & 0xff0000) >> 16);
b[offset + 3] = (byte) ((value & 0xff000000) >> 24);
Object[]toArray(int[] intArray)
to Array
if (intArray == null)
    return null;
Integer[] objArray = new Integer[intArray.length];
for (int i = 0; i < intArray.length; i++)
    objArray[i] = new Integer(intArray[i]);
return objArray;
StringtoArray(Iterable itr)
to Array
StringBuffer sb = new StringBuffer(32);
sb.append('[');
for (Object obj : itr) {
    if (obj instanceof String) {
        sb.append('\'').append(obj).append("',");
if (sb.length() > 1)
...
voidtoArray(long l, byte[] b, int offset)
Encodes the specified long in 4 consecutive bytes (big-endian) in the specified array, beginning at the specified offset.
b[offset + 3] = (byte) (l % 256);
l >>>= 8;
b[offset + 2] = (byte) (l % 256);
l >>>= 8;
b[offset + 1] = (byte) (l % 256);
l >>>= 8;
b[0] = (byte) (l % 256);
voidtoArray(long value, byte[] dest, int offset, int length)
Converts a long value to a short array.
The long value could be positive or negative.
for (int x = 0; x < length; x++) {
    dest[offset + x] = (byte) (value >>> (8 * x));
Object[]toArray(Object a)
Gives an Object array containing the passed parameter
return new Object[] { a };
Object[]toArray(Object foo)
to Array
if (foo.getClass().isArray()) {
    return (Object[]) foo;
return null;
Object[]toArray(Object o)
Convert object into one element array if it's not an array already.
if (o.getClass().isArray()) {
    return (Object[]) o;
return new Object[] { o };