0

在我的编程中,我不知道我需要为处理它的某个对象读取多少字节。但我知道它最多是 1024 字节。

处理完对象后,我怎样才能将剩余的字节放回文件中,即,将 fc 反转为剩余字节数。

我的意思是我可以让文件通道返回一定数量的字节,比如从当前位置返回 4 个字节吗?–

4

1 回答 1

0

Using FileChannels you can get and set the position very easily.

FileChannel channel = ...
// rewind 4 bytes
channel .position(channel .position()-4);
于 2014-04-14T21:48:44.000 回答