file = new RandomAccessFile(filename, "rw");
channel = file.getChannel();
MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
buffer.load();
for (int i = 0; i < buffer.limit(); i++)
{
System.out.print((char) buffer.getChar());
}
然而,这会吐出非 UTF8 字符。我知道我在这里遗漏了一些小东西!