Send String ArrayList via UDP in java

0

Hello, the question is this: How do I send an entire ArrayList via UDP from the server to the client in Java? I can send a String only one at a time and it works very well. But I do not know how to send an ArrayList of Strings.

Part of my code

SERVER

DatagramPacket request = new DatagramPacket(buffer, buffer.length);
    request.setData("Testando".getData());
    DatagramPacket reply = 
    new DatagramPacket(request.getData(), request.getLength(), request.getAddress(), request.getPort());
    aSocket.send(reply);

CLIENT

byte[] buffer = new byte[100];
            DatagramPacket reply = new DatagramPacket(buffer, buffer.length);
            aSocket.receive(reply);
            System.out.println("Resposta:" + new String(reply.getData()));

In this way I can send the word "Testing" from the server to the client. But I wanted to send an ArrayList of Strings!

    
asked by anonymous 25.03.2017 / 23:06

0 answers