while (buf.hasRemaining()) { // same as other channel, just write to it sink.write(buf); }
Read
1 2 3 4 5 6
// get source/read end of pipe Pipe.SourceChannelsource= pipe.source(); buf.clear(); // same as other channel, simply read it into byte buffer source.read(buf); System.out.println(newString(buf.array()));