Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Object I/O

 
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
 
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!