Skip to main content

Convert a byte array to integer in javaJava and vice versa

I want to store some data into bytearraysbyte arrays in Java. Basically just numbers which can take up to 2 Bytes per number.

I'd like to know how I can convert an integer into a 2 byte long bytearraybyte array and visevice versa. I found a lot of solutions googelinggoogling but most of them don't explain what happens in the code. There's a lot of shifting stuff I don't really understand so I would appreciate a basic explanation.

Convert a byte array to integer in java and vice versa

I want to store some data into bytearrays in Java. Basically just numbers which can take up to 2 Bytes per number.

I'd like to know how I can convert an integer into a 2 byte long bytearray and vise versa. I found a lot of solutions googeling but most of them don't explain what happens in the code. There's a lot of shifting stuff I don't really understand so I would appreciate a basic explanation.

Convert a byte array to integer in Java and vice versa

I want to store some data into byte arrays in Java. Basically just numbers which can take up to 2 Bytes per number.

I'd like to know how I can convert an integer into a 2 byte long byte array and vice versa. I found a lot of solutions googling but most of them don't explain what happens in the code. There's a lot of shifting stuff I don't really understand so I would appreciate a basic explanation.

edited title
Link
Jamel Toms
  • 4.6k
  • 2
  • 29
  • 27

Convert a byte array to integer in java and visevice versa

deleted 19 characters in body
Source Link
ROMANIA_engineer
  • 57k
  • 30
  • 211
  • 207

I want to store some data into bytearrays in javaJava. BasiclyBasically just numbers which can take up to 2 Bytes per number.

I'd like to know how iI can convert an integer into a 2 byte long bytearray and vise versa. I found a lot of solutions googeling but most of them don't explain what happens in the code. There's a lot of shifting stuff iI don't really understand so iI would appreciate a basic explanation.

thanks in advance

I want to store some data into bytearrays in java. Basicly just numbers which can take up to 2 Bytes per number.

I'd like to know how i can convert an integer into a 2 byte long bytearray and vise versa. I found a lot of solutions googeling but most of them don't explain what happens in the code. There's a lot of shifting stuff i don't really understand so i would appreciate a basic explanation.

thanks in advance

I want to store some data into bytearrays in Java. Basically just numbers which can take up to 2 Bytes per number.

I'd like to know how I can convert an integer into a 2 byte long bytearray and vise versa. I found a lot of solutions googeling but most of them don't explain what happens in the code. There's a lot of shifting stuff I don't really understand so I would appreciate a basic explanation.

Source Link
Chris
  • 7.8k
  • 8
  • 54
  • 103
Loading