Copies the contents of the buffer to a new ByteArray and returns the new array.
New ByteArray instance containing contents of the buffer.