I think there is no need to create a new byte array and fill it just to compare it. Just loop through the bytes and compare them. Even better would be to use a ByteBufProcessor for maximal performance.