2
* Copyright 2001-2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
16
package org.apache.commons.io.input;
18
import java.io.IOException;
19
import java.io.InputStream;
22
* Used in debugging, it counts the number of bytes that pass
25
* @author <a href="mailto:bayard@apache.org">Henri Yandell</a>
26
* @version $Id: CountingInputStream.java,v 1.8 2004/02/23 04:38:52 bayard Exp $
28
public class CountingInputStream extends ProxyInputStream {
33
* Constructs a new CountingInputStream.
34
* @param in InputStream to delegate to
36
public CountingInputStream( InputStream in ) {
41
* Increases the count by super.read(b)'s return count
43
* @see java.io.InputStream#read(byte[])
45
public int read(byte[] b) throws IOException {
46
int found = super.read(b);
52
* Increases the count by super.read(b, off, len)'s return count
54
* @see java.io.InputStream#read(byte[], int, int)
56
public int read(byte[] b, int off, int len) throws IOException {
57
int found = super.read(b, off, len);
63
* Increases the count by 1.
65
* @see java.io.InputStream#read()
67
public int read() throws IOException {
73
* The number of bytes that have passed through this stream.
75
* @return the number of bytes accumulated
77
public int getCount() {