Java Utililty Methods Array Copy

List of utility methods to do Array Copy

Description

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

Method

boolean[]copyOf(boolean[] t)
copy Of
boolean[] out = new boolean[t.length];
for (int i = 0; i < t.length; i++) {
    out[i] = t[i];
return out;
T[]copyOf(final U[] original, final int newLength, final Class newType)
Copy of.
return Arrays.copyOf(original, newLength, newType);
T[]copyOf(T[] array)
Return a copy of the array.
return Arrays.copyOf(array, array.length);
T[]copyOf(T[] array, int count)
copy Of
return Arrays.copyOf(array, count);
T[]copyOf(T[] original)
copy Of
if (original == null) {
    return null;
return (T[]) Arrays.copyOf(original, original.length, original.getClass());
T[]copyOf(T[] original)
Returns a copy of the specified array.
return Arrays.copyOf(original, original.length);
byte[]copyOfBytes(final byte[] bytes)
Returns a copy of the provided byte array.
return Arrays.copyOf(bytes, bytes.length);
T[]copyOfRange(U[] original, int from, int to, Class newType)
Same as Arrays#copyOfRange(Object[],int,int,Class)
return Arrays.copyOfRange(original, from, to, newType);
String[]copyStringArray(String[] str, int startingPos)
Takes a string array and returns a new copy from it.
try {
    return Arrays.copyOfRange(str, startingPos, str.length);
} catch (NullPointerException e) {
    return new String[0];
} catch (IllegalArgumentException e) {
    return new String[0];
} catch (ArrayIndexOutOfBoundsException e) {
    return new String[0];
...
byte[]getArrayCopy(byte[] array)
Copies an array.
byte[] bytes = null;
if (array != null) {
    bytes = Arrays.copyOf(array, array.length);
return bytes;