我有一个非常大的文件(可能是1G),我想以相反的顺序(以Java)创建一个新文件。 例如:读取并按相反顺序写入文件 - Java
Original file:
This is the first line
This is the 2nd line
This is the 3rd line
The reversed file:
This is the 3rd line
This is the 2nd line
This is the first line
由于文件是非常大的,一次加载整个文件到内存和反向排序可能有问题(有是我可以使用内存的限制)。 我如何在Java中实现这一点?
谢谢
这让我想起了一个(可能是面试)问题(找不到它,认为它在http://programmers.stackexchange.com某处),你必须在100Gb中对行进行排序只使用1Gb RAM的120Gb磁盘上的文本文件。 – Qwerky