• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on BufferedWriter

 
Sanju Shah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have question on bufferedWriter. Following is what I'm trying to do( i have provided just the jest ) .I have opened a socketconnection and application will be sending messages to the client

BufferedWriter bw = new BufferedWriter( new OutputStreamWriter( _socket.getOutputStream() ) );

bw.write( "AAAAA" );
bw.flush();
" some logic here "
bw.write( "BBBB" );
bw.flush();
" some logic here "
bw.write( "CCCC" );
bw.flush();

When I run the application sometimes it so happens that the client is just seeing "CCCC" getting printed instead of all the 3 printout statements. I'm not sure why it happens. It doesn't happen all the time.

Any idea what I'm doing wrong. I'm new to java so please bare with me


thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will never happen that the earlier data just "disappears." It might be that the client is inadvertently discarding the information, though.
 
Sanju Shah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing I forgot to mention is that the client gets "CCC" only first time when it logs in but after that whenever it communicates with the server app, it gets all the 3 messages.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps we need to see the client code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!