1 47 package com.lowagie.text.pdf; 48 import java.io.IOException ; 49 import java.io.OutputStream ; 50 51 55 public class OutputStreamCounter extends OutputStream { 56 57 protected OutputStream out; 58 protected int counter = 0; 59 60 61 public OutputStreamCounter(OutputStream out) { 62 this.out = out; 63 } 64 65 75 public void close() throws IOException { 76 out.close(); 77 } 78 79 91 public void flush() throws IOException { 92 out.flush(); 93 } 94 95 105 public void write(byte[] b) throws IOException { 106 counter += b.length; 107 out.write(b); 108 } 109 110 125 public void write(int b) throws IOException { 126 ++counter; 127 out.write(b); 128 } 129 130 158 public void write(byte[] b, int off, int len) throws IOException { 159 counter += len; 160 out.write(b, off, len); 161 } 162 163 public int getCounter() { 164 return counter; 165 } 166 167 public void resetCounter() { 168 counter = 0; 169 } 170 } 171 | Popular Tags |