Java 基础之IO 和NIO 补完等。参考java文档。 ### 17. Java NIO AsynchronousFileChannel ● java7中AsynchronousFileChannel加入到了java NIO的包中。AsynchronousFileChannels使得步读写文件实现。 ### 1. Creating an AsynchronousFileChannel Path path = Paths.get("data/test get("data/test.xml"); AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(path, StandardOpenOption.READ); ### 2. Reading Data ## • Reading Data Via a Future Futureoperation operation = fileChannel.read(buffer, 0); AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(path, StandardOpenOption.READ); ByteBuffer buffer = ByteBuffer.allocate(1024); long position = 0; Future 0 码力 | 9 页 | 218.38 KB | 2 年前3
共 1 条
- 1













