This is the mail archive of the java-prs@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]