[Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters?

wayne dot gray at coynetextileservices dot com gcc-bugzilla@gcc.gnu.org
Tue Nov 9 13:37:00 GMT 2004


------- Additional Comments From wayne dot gray at coynetextileservices dot com  2004-11-09 13:36 -------
(In reply to comment #3)
> The code says:
> 
>   while (br.read(charBuff,0,fileLength) != -1) 
>     bw.write(charBuff,0,fileLength); 
> 
> There is no guarantee that read() will fill the buffer.
> If you see a partial read, you will then write a full buffer,
> meaning that the remainder of the buffer will be zero
> (or leftovers from an earlier read).
> 
> So, I think this is not a libgcj bug.
> 

I see what you're saying.  But if that were true then the while loop would have
multiple iterations.  No?

The read and write methods are only being called once in this method for this
file.  Just confirmed with another test.

This is true because I'm sizing the buffer to the length of the file and... 

  br.read(charBuff,0,fileLength)

...reads the entire file length in the first shot.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18376



More information about the Gcc-bugs mailing list