List of utility methods to do Array Range Copy
byte[] | copyOf(byte[] original, int newLength) Implementation of JDK 1.6 Arrays.copyOf() method byte[] copy = new byte[newLength]; System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); return copy; |
byte[] | copyOf(byte[] source, int newLength) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. byte[] result = new byte[newLength]; System.arraycopy(source, 0, result, 0, Math.min(source.length, newLength)); return result; |
byte[] | copyOf(byte[] src, int length) byte array copy. return copyOf(src, 0, length);
|
char[] | copyOf(char[] array) copy Of int len = array.length; char[] copy = new char[len]; System.arraycopy(array, 0, copy, 0, len); return copy; |
char[] | copyOf(char[] source) copy Of final char[] copy = source != null ? new char[source.length] : null; if (copy != null) { System.arraycopy(source, 0, copy, 0, source.length); return copy; |
double[] | copyOf(double[] array, int length) copy Of double[] result = new double[length]; int n = Math.min(length, array.length); for (int i = 0; i < n; i++) { result[i] = array[i]; return result; |
double[] | copyOf(double[] v, int newlength) copy Of double[] ret = new double[newlength]; System.arraycopy(v, 0, ret, 0, Math.min(newlength, v.length)); return ret; |
byte[] | copyOf(final byte[] bytes) copy Of final byte[] copy = new byte[bytes.length]; System.arraycopy(bytes, 0, copy, 0, bytes.length); return copy; |
int[] | copyOf(int[] arr) copy Of int[] carr = new int[0]; if (arr != null) { carr = new int[arr.length]; System.arraycopy(arr, 0, carr, 0, arr.length); return carr; |
int[] | copyOf(int[] arr, int length) copy Of int[] copy = new int[arr.length]; System.arraycopy(arr, 0, copy, 0, length); return copy; |