1 22 23 package com.izforge.izpack.compiler; 24 25 import java.io.IOException ; 26 import java.io.OutputStream ; 27 28 31 public class ByteCountingOutputStream extends OutputStream 32 { 33 34 private long count; 35 36 private OutputStream os; 37 38 public ByteCountingOutputStream(OutputStream os) 39 { 40 this.os = os; 41 } 42 43 public void write(byte[] b, int off, int len) throws IOException 44 { 45 os.write(b, off, len); 46 count += len; 47 } 48 49 public void write(byte[] b) throws IOException 50 { 51 os.write(b); 52 count += b.length; 53 } 54 55 public void write(int b) throws IOException 56 { 57 os.write(b); 58 count += 4; 59 } 60 61 public void close() throws IOException 62 { 63 os.close(); 64 } 65 66 public void flush() throws IOException 67 { 68 os.flush(); 69 } 70 71 public long getByteCount() 72 { 73 return count; 74 } 75 } 76 | Popular Tags |