Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Urgent! Last character is lost in datagrams

Karthik Veeramani
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if this belongs to IO forum or this forum, but pls help.
I read datagrams and write the data to file. I use DatagramPacket and pass a byte array of size 1024. Then I use BufferedWriter coupled with FileWriter to write to file.
When i send some datagrams slowly 1 by 1, it gets into the file fully. but if i send at a faster rate, say 2 datagrams 1 after the other, the last character in alternate messages are lost. i.e, if i send a datagram message "Hello" 2 times, i get in the file "Hello", followed by "Hell".
Please help me to correct this.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic