Convert ArrayList to byte []

后端 未结 3 1798
面向向阳花
面向向阳花 2021-01-04 03:37

I have an ArrayList that i want to send through UDP but the send method requires byte[].

Can anyone tell me how to convert m

3条回答
  •  滥情空心
    2021-01-04 04:18

    If the other side is also java, you can use ObjectOutputStream. It will serialize the object (you can use a ByteArrayOutputStream to get the bytes written)

提交回复
热议问题