Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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
 
Yeah, but is it art? What do you think tiny ad?
ScroogeXHTML 9.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/731949/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic