我有一个 250 行的文件。我想在第 128 行之后插入一些文本。
我只发现我可以在文件末尾附加一个文本,比如
try {
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("outfilename", true)));
    out.println("the text");
    out.close();
} catch (IOException e) {
    //oh noes!
}
可以在这篇文章如何将文本附加到 Java 中的现有文件中找到
但没有提及行号或某事。