FileOutputStream o = null;
File file = null;
FileWriter fw = null;
byte[] buff = new byte[]{};
try {
file = new File("F:\\data.txt");
if (!file.exists()) {
file.createNewFile();
}
for (需要遍历的数据) {
String s = "组装的信息" + "\r\n";
buff = s.getBytes();
o = new FileOutputStream(file, true);
o.write(buff);
o.flush();
o.close();
}
System.out.println("写数据成功!");
} catch (IOException | ParseException e) {
e.printStackTrace();
}
标签:Java,写入,FileOutputStream,file,new,null,写法,buff From: https://www.cnblogs.com/hg-blogs/p/17096096.html