Pipe管道

创建管道(Creating a Pipe)
向管道写入数据(Writing to a Pipe)
从管道读取数据(Reading from a Pipe)
Last updated

Last updated
Pipe pipe = Pipe.open();Pipe.SinkChannel sinkChannel = pipe.sink();String newData = "New String to write to file..." + System.currentTimeMillis();
ByteBuffer buf = ByteBuffer.allocate(48);
buf.clear();
buf.put(newData.getBytes());
buf.flip();
while(buf.hasRemaining()) {
sinkChannel.write(buf);
}Pipe.SourceChannel sourceChannel = pipe.source();ByteBuffer buf = ByteBuffer.allocate(48);
int bytesRead = inChannel.read(buf);