From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2490 invoked by alias); 9 Nov 2004 13:37:07 -0000 Mailing-List: contact java-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-prs-owner@gcc.gnu.org Received: (qmail 2447 invoked by uid 48); 9 Nov 2004 13:37:03 -0000 Date: Tue, 09 Nov 2004 13:37:00 -0000 Message-ID: <20041109133703.2446.qmail@sourceware.org> From: "wayne dot gray at coynetextileservices dot com" To: java-prs@gcc.gnu.org In-Reply-To: <20041108145729.18376.wayne.gray@coynetextileservices.com> References: <20041108145729.18376.wayne.gray@coynetextileservices.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libgcj/18376] java.io.BufferedWriter outputing extraneous characters? X-Bugzilla-Reason: CC X-SW-Source: 2004-q4/txt/msg00347.txt.bz2 List-Id: ------- 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