# 2 楼答案 如果您在Java7中使用了新的,那么您可以使用这种方式 try (BufferedWriter writer = Files.newBufferedWriter(outFile, StandardCharsets.UTF_8, StandardOpenOption.APPEND))
# 3 楼答案 你的意思是“如何附加到文件”?查找文件编写类的[append version of a constructor][1],例如: public FileWriter(String fileName, boolean append) throws IOException 使用此构造函数并为append参数传递true [1]:http://download.oracle.com/javase/6/docs/api/java/io/FileWriter.html#FileWriter(java.io.File,布尔值)
# 1 楼答案
使用
new FileOutputStream(file, true)
。这将以“追加”模式打开文件,将写入流的所有数据追加到该文件的末尾# 2 楼答案
如果您在Java7中使用了新的,那么您可以使用这种方式
# 3 楼答案
你的意思是“如何附加到文件”?查找文件编写类的[append version of a constructor][1],例如:
使用此构造函数并为append参数传递
true
[1]:http://download.oracle.com/javase/6/docs/api/java/io/FileWriter.html#FileWriter(java.io.File,布尔值)