01: /*
02: * ====================================================================
03: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
04: *
05: * This software is licensed as described in the file COPYING, which
06: * you should have received as part of this distribution. The terms
07: * are also available at http://svnkit.com/license.html
08: * If newer versions of this license are posted there, you may use a
09: * newer version instead, at your option.
10: * ====================================================================
11: */
12: package org.tmatesoft.svn.core.internal.io.fs;
13:
14: import java.io.FilterOutputStream;
15: import java.io.IOException;
16: import java.io.OutputStream;
17:
18: /**
19: * @version 1.1.1
20: * @author TMate Software Ltd.
21: */
22: public class CountingStream extends FilterOutputStream {
23:
24: private long myPosition;
25:
26: public CountingStream(OutputStream stream, long offset) {
27: super (stream);
28: myPosition = offset >= 0 ? offset : 0;
29: }
30:
31: public void write(byte[] b, int off, int len) throws IOException {
32: super .out.write(b, off, len);
33: myPosition += len;
34: }
35:
36: public void write(int b) throws IOException {
37: super .write(b);
38: myPosition++;
39: }
40:
41: public long getPosition() {
42: return myPosition;
43: }
44: }
|