Index: java/io/BufferedInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/BufferedInputStream.java,v
retrieving revision 1.11
diff -u -r1.11 BufferedInputStream.java
--- java/io/BufferedInputStream.java	9 Mar 2004 07:48:56 -0000	1.11
+++ java/io/BufferedInputStream.java	30 Jun 2004 10:15:08 -0000
@@ -241,9 +241,12 @@
    * This method reads bytes from a stream and stores them into a caller
    * supplied buffer.  It starts storing the data at index <code>off</code>
    * into the buffer and attempts to read <code>len</code> bytes.  This method
-   * can return before reading the number of bytes requested.  The actual
-   * number of bytes read is returned as an int.  A -1 is returned to indicate
-   * the end of the stream.
+   * can return before reading the number of bytes requested, but it will try
+   * to read the requested number of bytes by repeatedly calling the underlying
+   * stream as long as available() for this stream continues to return a
+   * non-zero value (or until the requested number of bytes have been read).
+   * The actual number of bytes read is returned as an int.  A -1 is returned
+   * to indicate the end of the stream.
    * <p>
    * This method will block until some data can be read.
    *
@@ -266,14 +269,26 @@
     if (pos >= count && !refill())
       return -1;		// No bytes were read before EOF.
 
-    int remain = Math.min(count - pos, len);
-    System.arraycopy(buf, pos, b, off, remain);
-    pos += remain;
+    int totalBytesRead = Math.min(count - pos, len);
+    System.arraycopy(buf, pos, b, off, totalBytesRead);
+    pos += totalBytesRead;
+    off += totalBytesRead;
+    len -= totalBytesRead;
 
     if (markpos >= 0 && pos - markpos > marktarget)
       markpos = -1;
 
-    return remain;
+    while (len > 0 && super.available() > 0 && refill())
+      {
+	int remain = Math.min(count - pos, len);
+	System.arraycopy(buf, pos, b, off, remain);
+	pos += remain;
+	off += remain;
+	len -= remain;
+	totalBytesRead += remain;
+      }
+
+    return totalBytesRead;
   }
 
   /**
