Oleh Ponomarenko
02/20/2019, 3:35 PMdalexander
02/20/2019, 3:40 PMSystem.arrayCopy()
to copy the existing ByteArray into the new ByteArray starting at index 1. Set index 0 equal to your new value. Note that if performance is a concern you probably want to figure out a way to avoid doing this operation.Dico
02/20/2019, 3:54 PMSystem.arraycopy
(which will work) you should use oldArray.copyInto
which is available in the kotlin stdlib on all platforms.val newArray = byteArrayOf(elemToAdd, *oldArray)
.