Java RandomAccessFile crop from the start

I know how to trim a RandomAccess file to remove bytes at the end.

raf.getChannel().truncate(file.length() - 4);

or

raf.setLength(file.length() - 4);

But how to trim the RandomAccessFile so that the bytes at the beginning are deleted? I do not need to write the contents of this file to a new file. I googled and could not find the answer. Please help. Thanks in advance.

+5
source share
1 answer

This is not an operation that most file systems support. A model is a sequence of bytes, starting at a specific place on the disk. Files are variable in length and can be added, and therefore truncation is relatively difficult.

. . (, ) , , .

+5

All Articles