Can you guys run this program, I'm having issues running it.
import java.io.*;
import java.util.*;
//class definition
public class NumberAdder {
//The main function
public static void main(String args[]) {
//This declares a file to open.
File outFile = new File("numbers.dat");
int sumEven = 0;
int sumOdd = 0;
//File IO requires a try/catch block to prevent the program from crashing
try {
//a buffered writer is used to allow us to write to the file.
BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
//This for loop handles adding all of the numbers together
for(int i = 1; i < 100; i += 2) {
sumEven += i + 1;
writer.writer("" + sumEven + ", ");
}
//adding a new line and closing the file
writer.newLine();
writer.close();
//A buffered Reader is used for reading a new file.
BufferedReader reader = new BufferedReader(new FileReader(outFile));
//Because we only add a new line at the end, we only need to read the first line.
System.out.println(reader.readLine());
//we need to write again, so we close the reader and open the writer.
reader.close();
writer.open();
//This for loop is identical to the previous one, except for odd numbers
for(int i = 1; i < 100; i += 2) {
sumOdd += i;
writer.writer("" + sumOdd + ", ");
}
writer.newLine();
writer.close();
reader.open();
System.out.println(reader.readLine());
}
catch (Exception e) {
}
}
}