I'm getting multiple erros with this part of my program. What it basically does is read input from an unorganized file, PersonnelInfo.txt, and it sorts it into an array in the EmployeeInfo class (not posted because I don't believe the problem lies in that class, if you guys want, I will post it for reference).
After sorting the info (Like Name, ID number, title at the company, etc.) the program writes this to another file, ORGANIZEDPersonnelInfo.txt, which will be sorted as such:
Name: Employee name here
ID: Employee ID here
etc.
One error I am getting is in the "static FileWriter writeOut..." line and it is "Unhandled exception type IOException. I put a throws IOException in the main method declaration but it did nothing.
Next, in the "public String toString()" method I am receiving multiple errors. When I try to make it void, it says the return type is incompatible with Object.toString(). When I keep it as a String and return null it wants me to use try/catch but the main error still exists.
Please help! This is getting pretty frustrating...
import java.io.*;
import java.util.Scanner;
public class HR {
static EmployeeInfo[] employee = new EmployeeInfo[4];
static FileWriter writeOut = new FileWriter("/Users/zach/Documents/workspace/Dec. 10, 2012/src/ORAGNIZEDPersonnelInfo.txt");
static BufferedWriter out = new BufferedWriter(writeOut);
public static void main(String[] args) throws IOException {
File PersonnelInfo = new File("/Users/zach/Documents/workspace/Dec. 10, 2012/src/PersonnelInfo.txt");
Scanner inputFile = new Scanner(PersonnelInfo);
int numOfEmployees = Integer.parseInt(inputFile.nextLine());
System.out.println("Number of employees: " + numOfEmployees);
for (int i = 0; i < 4; i++) {
String name = inputFile.nextLine();
String ID = inputFile.nextLine();
String title= inputFile.nextLine();
String startDate = inputFile.nextLine();
employee[i] = new EmployeeInfo(name, ID, title, startDate);
}
listEmployeeInfo();
employee.toString();
}
public String toString() {
for (EmployeeInfo i: employee) {
out.write("Name: " + i.getName());
out.write("ID: " + i.getID());
out.write("Title: " + i.getTitle());
out.write("Start Date: " + i.getStartDate());
}
return null;
}