Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我用过Filewriter类。但它会附加在文件的末尾。谁能告诉我将内容附加到文件开头而不覆盖的方法。
Filewriter
你不能,基本上。这与其说是 Java 限制,不如说是文件系统限制——我不记得曾经见过允许这样做的 API。
您需要创建一个新文件,写入新数据,然后将原始文件的内容附加到其中。