0

So I was wondering if there was any way to turn a 2d double(or int) array into a 2d byte array and vice versa.

I want to have a list of variables(like player info and AI position and animations for both) to be sent over a Datagram socket and I looked around but couldn't find an answer.

Thanks for your help

Galindan
  • 11
  • 2
  • 2
    Possible duplicate of [Convert double to byte\[\] array](http://stackoverflow.com/questions/13071777/convert-double-to-byte-array) – talex Nov 09 '16 at 18:35

1 Answers1

0

Instead of dealing with difficult conversions, you should serialize the array, then send it through the socket and deserialize it again. You can do so with an ObjectInputStream and an ObjectOutputStream as presented here or use any other serialization library.

Community
  • 1
  • 1
thatguy
  • 21,059
  • 6
  • 30
  • 40
  • @talex You are right. This is just a **simple** way, if OP is a beginner. Nevertheless, I would recommend a specialized library for this, if the criteria is performance. – thatguy Nov 09 '16 at 18:54