Here you can find the source of invertByteArray(byte[] array)
public static void invertByteArray(byte[] array)
//package com.java2s; //License from project: Creative Commons License public class Main { public static void invertByteArray(byte[] array) { for (int i = 0; i < array.length; i++) { short temp = array[i]; // array[i] = (byte) ((short)Byte.MAX_VALUE - temp); // Compute as Short since Java uses signed bytes }//from ww w . j a v a2s . c o m } }