简体   繁体   English

Java RandomAccessFile setLength但是用于二进制文件的启动

[英]Java RandomAccessFile setLength but for the start of binary file

I've been reading on RandomAccessFile and understand that its possible to truncate the end of a file by setLength to a length shorter than the file. 我一直在阅读RandomAccessFile,并了解可以通过setLength将文件的末尾截断为比文件短的长度。 Im trying to copy just the "end" of the file to a new file and truncate the beginning. 我试图只将文件的“结束”复制到一个新文件并截断​​开头。

So for example: I want to delete the first 1300 bytes of a file and copy the rest of the file into a new file. 例如:我想删除文件的前1300个字节,并将文件的其余部分复制到新文件中。

Is there any way of doing this? 有没有办法做到这一点?

Cheers 干杯

您是否考虑过使用RandomAccessFile搜索方法寻找1300个字节,然后从偏移量开始读取文件的其余部分并使用另一个RandomAccessFile(或不同的流输出)来创建一个新文件,其中包含您从原始文件中读取的值文件以你指定的1300字节偏移量开始?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM