You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ba...@apache.org on 2003/11/23 10:18:55 UTC

cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io/input CountingInputStream.java

bayard      2003/11/23 01:18:55

  Modified:    io/src/java/org/apache/commons/io/input
                        CountingInputStream.java
  Log:
  modified so that when a read(byte[]) method returns a different number of bytes read than requested, the count is correct
  
  Revision  Changes    Path
  1.4       +8 -6      jakarta-commons-sandbox/io/src/java/org/apache/commons/io/input/CountingInputStream.java
  
  Index: CountingInputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/input/CountingInputStream.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CountingInputStream.java	13 Oct 2003 07:04:16 -0000	1.3
  +++ CountingInputStream.java	23 Nov 2003 09:18:55 -0000	1.4
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:bayard@apache.org">Henri Yandell</a>
    * @version $Id$
    */
  -public class CountingInputStream extends FilterInputStream {
  +public class CountingInputStream extends ProxyInputStream {
   
       private int count;
   
  @@ -78,14 +78,16 @@
   
       /** @see java.io.InputStream#read(byte[]) */
       public int read(byte[] b) throws IOException {
  -        count += b.length;
  -        return super.read(b);
  +        int found = super.read(b);
  +        count += found;
  +        return found;
       }
   
       /** @see java.io.InputStream#read(byte[], int, int) */
       public int read(byte[] b, int off, int len) throws IOException {
  -        count += len;
  -        return super.read(b, off, len);
  +        int found = super.read(b, off, len);
  +        count += found;
  +        return found;
       }
   
       /** @see java.io.InputStream#read() */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org