62,616
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) throws IOException {
RandomAccessFile f = new RandomAccessFile("jdk-7u7-windows-x64.exe", "r");
FileChannel fileChannel = f.getChannel();
ByteBuffer buffer = ByteBuffer.allocateDirect(10 * 1024 * 1024);
long pos = 0;
while(pos < f.length()){
pos += fileChannel.read(buffer, pos);
buffer.flip();
CharBuffer cBuffer = buffer.asCharBuffer();
/*
* 这里可以处理读字符
*
*/
buffer.clear();
System.out.println(pos);
}
}