oldOut = System.out


class NoOutputStream(OutputStream):

    def write(self, b, off, len):
        pass
System.setOut(PrintStream(NoOutputStream()))
System.out.println('foo')
System.setOut(oldOut)
System.out.println('foo')
Controlling stdout/stderr from Jython