1 16 package org.apache.commons.io.input; 17 18 import java.io.IOException ; 19 import java.io.InputStream ; 20 21 28 public class CountingInputStream extends ProxyInputStream { 29 30 private int count; 31 32 36 public CountingInputStream( InputStream in ) { 37 super(in); 38 } 39 40 45 public int read(byte[] b) throws IOException { 46 int found = super.read(b); 47 this.count += found; 48 return found; 49 } 50 51 56 public int read(byte[] b, int off, int len) throws IOException { 57 int found = super.read(b, off, len); 58 this.count += found; 59 return found; 60 } 61 62 67 public int read() throws IOException { 68 this.count++; 69 return super.read(); 70 } 71 72 77 public int getCount() { 78 return this.count; 79 } 80 81 } 82 | Popular Tags |