我想写内容到指定文件的第一行,即在文件的开始写入,而不是从文件的末尾写入。网上搜了一下,找到如下代码,可以指定位置写入,但是会把第一行的内容覆盖了,大家觉得这代码能改动使之不覆盖吗?或者有没有其他方法可以从文件开始中处写入内容?
try {
RandomAccessFile randomFile = new RandomAccessFile(fileName, "rw");
randomFile.seek(0);
randomFile.writeBytes(content);
randomFile.close();
} catch (IOException e) {
    e.printStackTrace();
}