commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io/input CountingInputStream.java
Date Sun, 23 Nov 2003 09:18:55 GMT
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


Mime
View raw message