This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
BufferedOutputStream patch
- To: java-discuss@sourceware.cygnus.com
- Subject: BufferedOutputStream patch
- From: jmc@cmpharm.ucsf.edu
- Date: Mon, 21 Jun 1999 16:30:37 -0700 (PDT)
I noticed that the write(byte[]) method of BufferedOutputStream
flushes immediately upon filling up the buffer; in a JVM (and
when using the write(byte) method), it doesn't flush until the next
write. As they say, "If it's yellow let it mellow..." Although
real apps shouldn't depend on either behavior, here is a patch
to make libgcj behave the same way a JVM does. I also confirmed
that BufferedWriter does not have the same bug:
diff -r -u libgcj-snapshot-1999-06-18.orig/libjava/java/io/BufferedOutputStream.java libgcj-snapshot-1999-06-18/libjava/java/io/BufferedOutputStream.java
--- libgcj-snapshot-1999-06-18.orig/libjava/java/io/BufferedOutputStream.java
Mon Jun 21 10:16:56 1999
+++ libgcj-snapshot-1999-06-18/libjava/java/io/BufferedOutputStream.java
Mon Jun 21 10:23:19 1999
@@ -56,7 +56,7 @@
throws IOException, NullPointerException, IndexOutOfBoundsException
{
// If LEN < 0 then the downstream write will fail for us.
- if (len >= 0 && count + len < buf.length)
+ if (len >= 0 && count + len <= buf.length)
{
System.arraycopy(b, off, buf, count, len);
count += len;
JMC
--
John-Marc Chandonia (jmc@cmpharm.ucsf.edu) We're everywhere...
Cohen Lab, University of California San Francisco for your convenience.
http://yuri.harvard.edu/~jmc -- Psi Corps <*>