Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

388
Views
How to Append Bytes to ByteArray in Kotlin

I am a beginner in Kotlin and I was trying to append bytes at the end of a ByteArray. How can I do that ?

Here is one way I tried. Does it look right?

var someByteArray = byteArrayOf(*payload, 0x01.toByte())

where payload is a ByteArray

Your help is much appreciated

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

ByteArray overloads the plus operator, so you can just add to the previous value directly, or assign to a new array. For example:

val startArray = byteArrayOf(0x1, 0x2, 0x3)
val newArray = startArray + 0x4.toByte()

Or if you want to keep the mutable var, you can just plus-assign it:

var array = byteArrayOf(0x1, 0x2, 0x3)
array += 0x4.toByte()
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!