| 1 package com.quadcap.io; 2 3 40 41 import java.io.*; 42 43 import com.quadcap.util.Debug; 44 import com.quadcap.util.Util; 45 46 51 52 public class CountedOutputStream extends OutputStream { 53 OutputStream out; 54 int count = 0; 55 56 public CountedOutputStream(OutputStream os) { 57 this.out = os; 58 } 59 60 public void write(int b) throws IOException { 61 out.write(b); 62 count++; 63 } 64 65 public void write(byte[] buf, int offset, int len) throws IOException { 66 out.write(buf, offset, len); 67 count += len; 68 } 69 70 public void write(byte[] buf) throws IOException { 71 out.write(buf); 72 count += buf.length; 73 } 74 75 public void flush() throws IOException { 76 out.flush(); 77 } 78 79 public void close() throws IOException { 80 out.close(); 81 } 82 83 public int getCount() { 84 return count; 85 } 86 87 public void setCount(int count) { 88 this.count = count; 89 } 90 } 91 | Popular Tags |