3.62. kink/javahost/JAVA_OUTPUT

3.62.1. JAVA_OUTPUT.new(Stream)

`new` makes an `output` val which wraps a Java OutputStream object specified by `Stream` arg.

Preconditions:

• `Stream` must be a java val

• The object reference of `Stream` must be an instance of java.io.OutputStream.

Example:

:JAVA_OUTPUT.require_from('kink/javahost/')

:Baos_class <- JAVA.class('java.io.ByteArrayOutputStream')
:Baos <- Baos_class.new([])
CONTROL.with_on_exit{(:on_exit)
  :Out = JAVA_OUTPUT.new(Baos)
  on_exit{ Out.close }
  Out.write_byte(1)
  Out.write_byte(2)
  Out.write_byte(3)
}
:Bin <- Baos.call_method('toByteArray' []).to_kink_bin
stdout.print_line(Bin.repr)