0

so I have an ArrayList of items and I want to send it from the server I have to the client.

This actually works 100% apart from the fact that it's being returned like this(student is my class that implements serializable).

 myPackage.student@4554617c

How do i deserialize this on the client? Do I create a new arraylist and then pass in the object to that?

Relevant Server code:

    DataInputStream din = new DataInputStream(s.getInputStream());
    int num = din.readInt();

    ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());

    //get details is where im getting the arraylist from.
    out.writeObject (data.getDetails(num));  

Relevant Client code:

    //Get user input to select array element
    DataOutputStream out = new DataOutputStream(s.getOutputStream());
    out.writeInt(num);

    //get the data from the server
    ObjectInputStream objectInput = new ObjectInputStream(s.getInputStream());

    //Print the object we've got from the server
    Object test = objectInput.readObject();
    System.out.println(test);

I have googled and googled but I honestly have no clue what I am supposed. I know the client side isn't right, and that I can't just print the object. But I'm not sure what way to go about it.

Any help would be greatly greatly appreciated :)

Strobe_
  • 495
  • 1
  • 13
  • 34

0 Answers0