Use System.arraycopy to simplify the implementation a bit.