I have written this program but for some reason it isn't appending to the file?
import java.io.*;
public class numbers
{
public static void main(String[] args) throws IOException
{
FileWriter grades = new FileWriter(new File("grades.txt"));
String temp = "";
for (int i=0; i<=100; i+=2)
{
temp = String.valueOf(i);
grades.write(temp);
grades.write(",");
}
grades.close();
BufferedReader in = new BufferedReader(new FileReader("grades.txt"));
System.out.println("The output from the grades.txt file: ");
try
{
temp = in.readLine();
System.out.println(temp);
}
catch(IOException ioe)
{
System.err.println("Error: " + ioe.getMessage());
}
in.close();
FileWriter grades2 = new FileWriter("grades.txt", true);
String temp2 = "";
for (int j=1; j<=100; j+=2)
{
temp2 = String.valueOf(j);
grades2.write(temp2);
grades2.write(",");
}
BufferedReader inn = new BufferedReader(new FileReader("grades.txt"));
System.out.println("The output from the grades.txt file: ");
try
{
temp2 = inn.readLine();
System.out.println(temp2);
}
catch(IOException ioe)
{
System.err.println("Error: " + ioe.getMessage());
}
finally
{
inn.close();
}
}
}