有没有一种有效的方法来“收割”一个文件(从尾部删除x个字节)? [英] Is there an efficient way to "crop" a file (remove x number of bytes from tail)?
本文介绍了有没有一种有效的方法来“收割”一个文件(从尾部删除x个字节)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从原始文件中读取字节并将它们写入一个新文件看起来不正确(快),特别是如果文件是巨大的一个。
有没有办法可以设置文件长度
或者更确切地说, cropa file?
解决方案
RandomAccessFile.setLength(long newLength)
Good afternoon all. I was wondering how do we efficiently remove x number of bytes from the end of a file? (inverse operation of append)
Reading the bytes from the original file and writing them to a new file just doesn't seem right (fast) especially if the file is a huge one.
Is there a way we could possibly set the file length?
Or rather, what's the best way to "crop" a file?
解决方案
RandomAccessFile.setLength(long newLength)
这篇关于有没有一种有效的方法来“收割”一个文件(从尾部删除x个字节)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文