FileChannel fc = FileOutputStream("data.txt", "rw").getChannel();
.getChannel();
.getChannel();
.getChannel();
.getChannel();
.getChannel();
ByteBuffer buff = ByteBuffer.allocate();
fc.read(buff);
buff.flip()
while()
System.out.print();
NIO编程模型中,新来一个连接不再创建一个新的线程,而是可以把这条连接直接绑定到某个固定的线程,然后这条连接所有的读写都由这个线程来负责,那么他是怎么做到的?我们用一幅图来对比一下IO与NIO
new RandomAcessFile(“data.txt”, “rw”)
既用于读也用于写
(“data.txt”, “rw”);
(“data.txt”, “rw”);
CharBuffer();