-2
我想知道如何在不清除或清除文件的情况下向文件写入一行。我需要什么类和包? 我已经尝试过使用FileOutputStream和PrintStream(使用println)并使用BufferedWriter和OutputStreamWriter(使用write),但是它们从文件中删除了以前的内容。在不清除以前的内容的情况下写入txt文件
try
{
File txt = new File("marcos.txt");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
writer.write(registro);
writer.newLine();
writer.close();
}
catch(Exception e)
{
System.out.println("Error en la escritura al archivo.");
}