commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r767368 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
Date Wed, 22 Apr 2009 05:02:31 GMT
Author: grobmeier
Date: Wed Apr 22 05:02:30 2009
New Revision: 767368

URL: http://svn.apache.org/viewvc?rev=767368&view=rev
Log:
added byte counter

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java?rev=767368&r1=767367&r2=767368&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java
Wed Apr 22 05:02:30 2009
@@ -21,5 +21,25 @@
 import java.io.InputStream;
 
 public abstract class CompressorInputStream extends InputStream {
-    // TODO 
+    private int bytesRead = 0;
+    
+    /**
+     * Increments the counter of already read bytes.
+     * Doesn't increment if the EOF has been hit (read == -1)
+     * 
+     * @param read the number of bytes read
+     */
+    protected void count(int read) {
+        if(read != -1) {
+            bytesRead = bytesRead + read;
+        }
+    }
+    
+    /**
+     * Returns the current number of bytes read from this stream.
+     * @return the number of read bytes
+     */
+    public int getCount() {
+        return bytesRead;
+    }
 }



Mime
View raw message