Hi, I am trying to write my output into a text file using FileWriter.
I have about a thousand entries in my ArrayLists.
So what happen is it just prints out the last entry. I've gone through couple examples from web about FileWriter, it involves with looping for. Could anyone please teach me how to get it printed all entries in line.
Please help me to take a look at it....really appreciate any advice. Thank you.
I have about a thousand entries in my ArrayLists.
So what happen is it just prints out the last entry. I've gone through couple examples from web about FileWriter, it involves with looping for. Could anyone please teach me how to get it printed all entries in line.
Please help me to take a look at it....really appreciate any advice. Thank you.
Code:
myArrayList.add(new Entry(data, number, value)); //If print out myArrayList.size() = 1000.
try
{
// WRITE ENTRY TO FILE
output = new BufferedWriter( new FileWriter(FILENAME));
output.write(data+"\n");
output.write(number+"\n");
output.write(value+"\n");
output.close();
}
catch (IOException e)
{
System.out.println("There was a problem creating/writing to the temp file");
e.printStackTrace();
}
Comment