Can somebody help me, i want to save the output of this program in a .csv file but i don't know how. please i need help.
import java.io.*;
public class TestEmployee
{
public static void main(String args[]) throws IOException
{
Employee staff[] = new Employee[args.length];
// populating the array of Employee
for (int i = 0; i < args.length; i++)
{
String values[] = args[i].split(",");
if (values.length == 4)
{
staff[i] = new Manager(values[0], values[1], Double.parseDouble(values[2]), values[3]);
}
else if (values.length == 3)
{
if (Character.isDigit(values[2].charAt(0)))
staff[i] = new Employee(values[0], values[1], Double.parseDouble(values[2]));
else
staff[i] = new Manager(values[0], values[1], values[2]);
}
else if (values.length == 2)
{
staff[i] = new Employee(values[0], values[1]);
}
else
{}
}
// printing of the Employee array while computing
for (int i=0; i<staff.length; i++)
{
String values[]=args[i].split(",");
for(int a=0 ; a<values.length ; a++)
{
System.out.println("[Firstname Length: "+values[0].length()+" ]"
+"[Lastname Length: "+values[1].length()+" ]"
+"[Employee IDnumber: "+(i+1)+" ]"+" = "+ staff[i]);
a++;
}
}
}
}
The Employee and Manager.java is the main class.
Thank you in advance.