#CodeSnippet - Reverse a byte array in android
Reverse a byte array using the following code
public static void reverse(byte[] reverseArray) { // if array is empty return null if (reverseArray == null) { return; } //start index of array int i = 0; // get the length int j = reverseArray.length - 1; byte tmp; //for storing values for exchange purpose while (j > i) { tmp = array[j]; array[j] = array[i]; array[i] = tmp; j--; i++; } }
Comments
Post a Comment