Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8528
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Buffered reading seems to corrupt data stream |
| Date | 2011-10-04 08:48 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <19587162.2005.1317743300210.JavaMail.geo-discussion-forums@prfh23> (permalink) |
| References | <y4Cdne-uvN4kUBTTnZ2dnUVZ_hWdnZ2d@westnet.com.au> <j6cv50$2fk$2@dont-email.me> |
markspace wrote: > Qu0ll wrote: >> I am trying to repeatedly send a byte array from a server to a client >> where both the writing and the reading is done in a buffered manner with >> the following code on the server: >> >> DataOutputStream dos = new DataOutputStream(os); >> dos.writeInt(bytes.length); >> dos.write(bytes); >> dos.flush(); > > I got to repeat the request for an SSCCE. The code above is certainly > not where the problem is. The problems is certainly in some other area > which you haven't shown us. > > As a suggestion, scan the input above before you write it. You'll > certainly find the same values going in as you are reading back out. > Then trace the path up the input side to determine what is actually > writing that data in the the array "bytes". Just this once the question was answerable (and answered, elsethread) without the SSCCE, but truthfully the respondents had to infer the context that an SSCCE would've made explicit. They just happened to guess right. (Well, it was fairly obvious.) But to the OP and the rest of us, it really is a good idea to package your example as an SSCCE. Just because we think something is obvious doesn't mean everyone does. Coincidentally I was just facing the same problem in a project. I want to independently dip into an input stream without trashing the stream location by buffering. In my case I did away with the buffering, but for the OP's case here it is much easier to preserve the stream at wider scope than they originally had it. -- Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 01:58 +1100
Re: Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 02:26 +1100
Re: Buffered reading seems to corrupt data stream Ronny Schütz <usenet.r96@gishpuppy.com> - 2011-10-03 17:54 +0200
Re: Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 07:07 +1100
Re: Buffered reading seems to corrupt data stream Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-03 13:18 -0700
Re: Buffered reading seems to corrupt data stream "Qu0ll" <Qu0llSixFour@gmail.com> - 2011-10-04 10:54 +1100
Re: Buffered reading seems to corrupt data stream Roedy Green <see_website@mindprod.com.invalid> - 2011-10-03 11:46 -0700
Re: Buffered reading seems to corrupt data stream Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-10-03 08:44 -0700
Re: Buffered reading seems to corrupt data stream markspace <-@.> - 2011-10-03 11:33 -0700
Re: Buffered reading seems to corrupt data stream Lew <lewbloch@gmail.com> - 2011-10-04 08:48 -0700
Re: Buffered reading seems to corrupt data stream Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-10-04 09:07 -0700
Re: Buffered reading seems to corrupt data stream Lew <lewbloch@gmail.com> - 2011-10-04 12:06 -0700
csiph-web