The object in the ArrayList contains different primitive types and a strange type. Like
object = (int, float, float[], PApplet)
PApplet is descended from Applet, actually I do not what is it.
How to send this kind of ArrayList from a client to a server?
Than开发者_Go百科ks in advance!
Ok so i dont know if you are familiar with the concept of Serialization but heres some code that i think will help you out,
public class Packet implements Serializable
{
public Packet(int[] numArray, char[] letterArray, String wordArray)
{
this.numArray = numArray;
this.letterArray = letterArray;
this.wordArray = wordArray;
}
public int[] numArray;
public char[] letterArray;
public Stirng[] wordArray;
}
so now heres the other half, you have to use an objectStream, the code is somthing like:
try
{
ObjectOutputStream writer = new ObjectOutputStream(socket.getOutputStream());
writer.writeObject(new Packet(...data));
}catch(Exception e){e.printStackTrace();}
and then of course the server would have an ObjectInputStream and do the opposite, if you need anymore help just e-mail me and ill help you.
精彩评论