我正在创建一个应用程序文件,并且不断向该文件中写入一些内容。
但是当我的文件达到某个大小时,比如说100行,我想要删除第一行并将新的一行写在底部。
需求是我的文件应该有限制,但它应该保持我已经写入文件的最新内容。
请告诉我这是否可能在Java中实现?如果有其他替代方法,请告诉我。
this happened at that time
blah blah happened
*this is the current record
this was the fourth event to occur after startup
this was the fifth event to occur after startup
this was the sixth event to occur after startup
this was the seventh event to occur after startup
this was the eighth event to occur after startup
this was the ninth event to occur after startup
this was the tenth event to occur after startup
这样,您只需要打开文件,索引到当前行(因为您在程序中进行了跟踪,所以您知道当前行),并覆盖它,用空格填充到所选长度。然后索引回一个记录,并用空格替换星号。