I want to send an array of double as an object via ObjectOutputStream that uses a socket for outputStream. In the receiving side I read repetitious objects all the same! Maybe the assignment of method readObject doesn't perform it's task. I'm trying to update dobArray and write it to the socket output stream. dobArray is updated by another thread. It does it's task well, because I tested it. here is my code:
sending side:
objectStream = new ObjectOutputStream(dataFlow.getOutputStream());
while(busy){
try {
// dobArray is updated in another thread
objectStream.writeObject( dobArray);
} catch (IOException e) {
e.printStackTrace();
}
}
receiving side:
objectInputStream = new ObjectInputStream(
mainServer.dataFlow.getInputStream());
while (busy){
try {
DobArray dobarray =
(DobArray) objectInputStream.readObject()
writeToFile(dobarray);
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
regards sajad