1 package com.quadcap.io; 2 3 40 41 import java.io.InputStream ; 42 import java.io.IOException ; 43 44 import java.util.Vector ; 45 46 import com.quadcap.util.Debug; 47 48 54 public class CountedInputStream extends InputStream { 55 InputStream in; 56 int pos = 0; 57 58 64 public CountedInputStream(InputStream in) { 65 this.in = in; 66 } 67 68 73 public int read() throws IOException { 74 pos++; 75 return in.read(); 76 } 77 78 83 public int read(byte[] buf, int offset, int cnt) throws IOException { 84 int ret = in.read(buf, offset, cnt); 85 pos += ret; 86 return ret; 87 } 88 89 94 public int read(byte[] buf) throws IOException { 95 int ret = in.read(buf); 96 pos += ret; 97 return ret; 98 } 99 100 103 public int available() throws IOException { 104 return in.available(); 105 } 106 107 110 public void close() throws IOException { 111 in.close(); 112 } 113 114 117 public long skip(long n) throws IOException { 118 return in.skip(n); 119 } 120 121 124 public void mark(int readLimit) { 125 in.mark(readLimit); 126 } 127 128 131 public void reset() throws IOException { 132 in.reset(); 133 } 134 135 138 public boolean markSupported() { 139 return in.markSupported(); 140 } 141 142 145 public int getPosition() { 146 return pos; 147 } 148 149 152 public void setPosition(int pos) { 153 this.pos = pos; 154 } 155 156 } 157 | Popular Tags |