Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jteague.itco321.ip.week.pkg4;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Collections;
- class Employee{
- public String FirstName;
- public String LastName;
- public String Company;
- public String Address;
- public String City;
- public String County;
- public String State;
- public String Zip;
- public String Phone;
- public String Fax;
- public String Email;
- public String Web;
- public String toString(){
- return FirstName+" "+LastName+" "+Company+" "+Address+" "+City+" "+County+"
- "+State+" "+Zip+" "+Phone+" "+Phone+" "+Fax+" "+Email+" "+Web;
- }
- }
- public class JTeagueITCO321IPWeek4 {
- /**
- * @param args the command line arguments
- * @throws java.io.FileNotFoundException
- */
- public static void main(String[] args) throws FileNotFoundException,
- IOException {
- String line = "";
- ArrayList <Employee> ALEmployee = new ArrayList();
- FileReader fr = new
- FileReader("C:\Users\User\Downloads\ITCO321_U4IP_sample_data.csv");
- try (BufferedReader br = new BufferedReader(fr)) {
- while ((line = br.readLine())!=null){
- Employee emp = new Employee();
- String[] empFields = line.split(",");
- emp.FirstName = empFields[0];
- emp.LastName = empFields[1];
- emp.Company = empFields[2];
- emp.Address = empFields[3];
- emp.City = empFields[4];
- emp.County = empFields[5];
- emp.State = empFields[6];
- emp.Zip = empFields[7];
- emp.Phone = empFields[8];
- emp.Fax = empFields[9];
- emp.Email = empFields[10];
- emp.Web = empFields[11];
- ALEmployee.add(emp);
- }
- }
- ALEmployee.forEach((e) -> {
- System.out.println(e);
- });
- }
- }
Add Comment
Please, Sign In to add comment