I have a fixed length byte array and need to add two null bytes to its end. I have an implementation that I wrote to do this, though I was wondering whether someone could improve on what I have:
public byte[] appendNullBytes( byte[] bytes ) {
byte[] copyBytes = new byte[bytes.length+2];
System.arraycopy(bytes, 0, copyBytes, 0, bytes.length);
copyBytes[copyBytes.length-1] = 0;
copyBytes[copyBytes.length-2] = 0;
return copyBytes
}