1 16 17 package org.apache.log4j.helpers; 18 19 import java.io.Writer ; 20 import java.io.IOException ; 21 22 import org.apache.log4j.spi.ErrorHandler; 23 import org.apache.log4j.spi.ErrorCode; 24 25 32 public class CountingQuietWriter extends QuietWriter { 33 34 protected long count; 35 36 public 37 CountingQuietWriter(Writer writer, ErrorHandler eh) { 38 super(writer, eh); 39 } 40 41 public 42 void write(String string) { 43 try { 44 out.write(string); 45 count += string.length(); 46 } 47 catch(IOException e) { 48 errorHandler.error("Write failure.", e, ErrorCode.WRITE_FAILURE); 49 } 50 } 51 52 public 53 long getCount() { 54 return count; 55 } 56 57 public 58 void setCount(long count) { 59 this.count = count; 60 } 61 62 } 63 | Popular Tags |