0

In my programming, I do not know how many bytes I need to read for a certain object util I processed it. But I know at most it is 1024 bytes.

After processing the object, how can I put the remaining bytes back to the file i.e., revserse the fc by the number of remaning number of bytes.

I mean could I let the filechannel go back by a certain number of bytes, say 4 bytes from current position? –

user3495562
  • 335
  • 1
  • 4
  • 16

1 Answers1

0

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

FileChannel channel = ...
// rewind 4 bytes
channel .position(channel .position()-4);
ug_
  • 11,267
  • 2
  • 35
  • 52