def __init__(self, stdout=True):
    if stdout:
        self._original = System.out
        self._set_stream = System.setOut
    else:
        self._original = System.err
        self._set_stream = System.setErr
    self._bytes = ByteArrayOutputStream()
    self._stream = PrintStream(self._bytes, False, 'UTF-8')
    self._set_stream(self._stream)
def __init__(self, stdout=True):
    if stdout:
        self._original = System.out
        self._set_stream = System.setOut
    else:
        self._original = System.err
        self._set_stream = System.setErr
    self._bytes = ByteArrayOutputStream()
    self._stream = PrintStream(self._bytes, False, 'UTF-8')
    self._set_stream(self._stream)