fold

fun fold(sink: Sink)

Writes any buffered contents of this pipe to sink, then replace this pipe's source with sink. This pipe's source is closed and attempts to read it will throw an IllegalStateException.

This method must not be called while concurrently accessing this pipe's source. It is safe, however, to call this while concurrently writing this pipe's sink.