就是如何不覆盖的写入一个txt文件,不要把原来的内容覆盖掉,要加个什么定位语句,最好在下面的基础上加上。给高分啊!
FileWriter fileWriter=new FileWriter("c:\\Result.txt");
int [] a=new int[]{11112,222,333,444,555,666};
for (int i = 0; i < a.length; i++) {
fileWriter.write(String.valueOf(a[i])+" ");
}
fileWriter.flush();
fileWriter.close();
或者这个
try{
BufferedWriter writer = new BufferedWriter(new FileWriter(new File("c:\\Result.txt")));
writer.write("\"101\",\"英语\",\"english\",\"100001\"\r\n");
writer.close();
}catch(Exception e){
}
用另一个构造方法
FileWriter fileWriter=new FileWriter("c:\\Result.txt", true); // true代表追加
同理
BufferedWriter writer = new BufferedWriter(new FileWriter(new File("c:\\Result.txt"), true));