package aQute.junit;

import java.io.*;

public class Tee extends OutputStream {
	PrintStream				oldStream;
	ByteArrayOutputStream	buffer	= new ByteArrayOutputStream();
	boolean					capture;
	boolean					echo;

	public Tee(PrintStream oldOut) {
		oldStream = oldOut;
	}

	public PrintStream getStream() {
		try {
			return new PrintStream(this, false, "UTF-8");
		}
		catch (UnsupportedEncodingException e) {
			return null;
		}
	}

	@Override
	public void write(int character) throws IOException {
		if (capture)
			buffer.write(character);
		if (echo)
			oldStream.write(character);
	}

	public String getContent() {
		if (buffer.size() == 0)
			return null;
		try {
			return buffer.toString("UTF-8");
		}
		catch (UnsupportedEncodingException e) {
			return null;
		}
	}

	public Tee clear() {
		buffer.reset();
		return this;
	}

	public Tee capture(boolean capture) {
		this.capture = capture;
		return this;
	}

	public Tee echo(boolean echo) {
		this.echo = echo;
		return this;
	}

}

@@ -32,16 +32,43 @@
 va.io.*;
+%0Aimport java.nio.charset.*;
 %0A%0Apublic
@@ -325,25 +325,16 @@
 eam() %7B%0A
-%09%09try %7B%0A%09
 %09%09return
@@ -358,93 +358,10 @@
 this
-, false, %22UTF-8%22);%0A%09%09%7D%0A%09%09catch (UnsupportedEncodingException e) %7B%0A%09%09%09return null;%0A%09%09%7D
+);
 %0A%09%7D%0A
@@ -627,15 +627,43 @@
 ing(
-%22UTF-8%22
+Charset.defaultCharset().toString()
 );%0A%09

Unnecessarily encoded into UTF-8