删除Java中文件的内容 [英] Delete Content of a File in Java
本文介绍了删除Java中文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将字节写入temp.fls文件.完成该操作后,我想从temp.fls文件中删除最后256个字节.我怎样才能做到这一点?请帮助我.
I'm writing bytes to temp.fls file. After completing the operation, I want to delete the last 256 bytes from the temp.fls file. How can I achieve this? Please help me.
谢谢.
推荐答案
Use RandomAccessFile.setLength()
like so:
RandomAccessFile f = new RandomAccessFile(yourFile,"rw");
f.setLength(f.length()-256);
这篇关于删除Java中文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文