Reputation: 353
Recently I am making a server-client program using multithread concept. For some reason, I have to sent an array of string from client to server. I am using ObjectOutputStream
and writeObject()
method to send that array of string. For example I have an array named String data[] = new String[3]
then I send it over socketwriteobject(data)
.
Question is, how do I receive this array of string on server? Is it ObjectInputStream
and this method readObject()
can help me? I just want to iterate this object and make it into new array of string in server side. For example String newData[] = new String[3]
and then put the string in data[0]
into newData[0]
until data[2]
into newData[2]
.
Upvotes: 2
Views: 2803
Reputation: 34367
I believe when you read your object using readObject()
, it should return your String[] itself.
String[] myObjects = (String[])inObjectStream.readObject();
Is that not working?
Upvotes: 3