for(int i=0; i<10; i++){
array[i] = (char)('a'+i);
}
RandomAccessFile rf = new RandomAccessFile("data1.txt", "rw");
FileChannel fc = rf.getChannel();
ByteBuffer buffer = null;
buffer = ByteBuffer.allocate(1024);
for(int i=0; i<10; i++){
buffer.putInt((int) array[i]);
}
buffer.flip();
fc.write(buffer);
上面的代码,我尝试将97,98 ...写入文件,当我从ByteBuffer中读取它然后将其打印到屏幕上时,它似乎是97,98,......
但是当我打开文件时,它显示为a,b,c .....
为什么