I have this to send string or integer but if i want to send a string array what should i use?
// A string ("Hello, World").
out.write("Hello, World".getBytes());
// An integer (123).
out.write(ByteBuffer.allocate(4).putInt(123).array());
Thanks in advance
Just write the array
If you're using
ObjectOutputStream
, there's no need to muck about with byte arrays - the class provides high-level methods to read and write entire objects.Similarly:
You only need to use the
write(byte[])
methods if you're using the raw, low-levelOutputStream
class.