1 22 package org.netbeans.lib.cvsclient.util; 23 24 import java.io.*; 25 26 31 public class LoggedDataOutputStream extends FilterOutputStream { 32 33 private long counter; 34 35 39 public LoggedDataOutputStream(OutputStream out) { 40 super(out); 41 } 42 43 51 public void writeChars(String line) throws IOException { 52 writeBytes(line); 53 } 54 55 60 public void writeBytes(String line) throws IOException { 61 byte[] bytes = line.getBytes(); 62 out.write(bytes); 63 Logger.logOutput(bytes); 64 counter += bytes.length; 65 } 66 67 70 public void writeBytes(String line, String encoding) throws IOException { 71 byte[] bytes = line.getBytes(encoding); 72 out.write(bytes); 73 Logger.logOutput(bytes); 74 counter += bytes.length; 75 } 76 77 public void write(int b) throws IOException { 78 super.write(b); 79 counter++; 80 } 81 82 public void write(byte b[]) throws IOException { 83 super.write(b); 84 counter += b.length; 85 } 86 87 public void write(byte b[], int off, int len) throws IOException { 88 super.write(b, off, len); 89 counter += len; 90 } 91 92 96 public void close() throws IOException { 97 out.close(); 98 } 99 100 public OutputStream getUnderlyingStream() { 101 return out; 102 } 103 104 public void setUnderlyingStream(OutputStream os) { 105 out = os; 106 } 107 108 public long getCounter() { 109 return counter; 110 } 111 } | Popular Tags |