You are recreating your byte array each time you iterate your for loop: for (int i = 0 ; i < b.length; i++) { result = new byte[b.length]; //
www.google.com.tw