• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object I/O  RSS feed

 
Ryan Langley
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,


Does anyone know of a good Object I/O tutorial for JAVA? I've looked around the 'net and I haven't been able to find a decent one. I'm having some trouble using Object streams over socket connections. I can send objects between them, but it seems that if I send an object over the stream, update it at a later time, and send the updated object over the stream it comes out the other end as the initial object.. Is there something simple I'm missing, or do object streams not allow you to update objects and re-send them over the stream? Any suggestions would be appreciated!


RL
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never had problems sending updated objects over a socket connection. It sounds to me like you might be accidentally using the same value over and over, maybe because the old value persists somewhere in your code and you're using that one. Make sure you flush your streams, too.
Originally posted by Ryan Langley:
Hello,

Does anyone know of a good Object I/O tutorial for JAVA? I've looked around the 'net and I haven't been able to find a decent one. I'm having some trouble using Object streams over socket connections. I can send objects between them, but it seems that if I send an object over the stream, update it at a later time, and send the updated object over the stream it comes out the other end as the initial object.. Is there something simple I'm missing, or do object streams not allow you to update objects and re-send them over the stream? Any suggestions would be appreciated!

RL

 
Ryan Langley
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Thanks for the suggestion.. It wasn't what the problem turned out to be, but it got me on the right track. The object I was sending had another object inside of it. Although I was changing that inner object, for some reason it wouldn't send it along inside the object I was sending. It appears that the object streams keep track of the address of the object that gets passsed over it. If the address of the object doesn't change, then it appears that it just uses the copy that it already sent. SO, I just created a new instance of the object and repolpulated it from the original object. I'm not sure if there is an easier way to do this, but it worked.. Maybe I could have used clone() or something. Oh well..
Cheers,
RL
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!