@@ -0,0 +1,1093 @@
+package com.hzh.corejava.nio;%0A%0Aimport java.io.IOException;%0Aimport java.nio.ByteBuffer;%0Aimport java.nio.channels.Pipe;%0A%0A/**%0A * Created by huangzehai on 2017/3/15.%0A */%0Apublic class PipeExample %7B%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        Pipe pipe = Pipe.open();%0A        Pipe.SinkChannel sinkChannel = pipe.sink();%0A        String newData = %22New String to write to file...%22 + System.currentTimeMillis();%0A%0A        ByteBuffer buf = ByteBuffer.allocate(48);%0A        buf.clear();%0A        buf.put(newData.getBytes());%0A        buf.flip();%0A%0A        while (buf.hasRemaining()) %7B%0A            sinkChannel.write(buf);%0A        %7D%0A%0A        Pipe.SourceChannel sourceChannel = pipe.source();%0A        ByteBuffer inBuffer = ByteBuffer.allocate(48);%0A        int bytesRead = sourceChannel.read(inBuffer);%0A        while (bytesRead != -1) %7B%0A            inBuffer.flip();%0A            while (inBuffer.hasRemaining()) %7B%0A                System.out.print((char) inBuffer.get());%0A            %7D%0A            inBuffer.clear();%0A            bytesRead = sourceChannel.read(inBuffer);%0A        %7D%0A    %7D%0A%7D%0A

Add Pipe example