Guest User

Untitled

a guest
Nov 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. package jteague.itco321.ip.week.pkg4;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileReader;
  6. import java.io.IOException;
  7. import java.util.ArrayList;
  8. import java.util.Collections;
  9.  
  10.  
  11.  
  12.  
  13. class Employee{
  14. public String FirstName;
  15. public String LastName;
  16. public String Company;
  17. public String Address;
  18. public String City;
  19. public String County;
  20. public String State;
  21. public String Zip;
  22. public String Phone;
  23. public String Fax;
  24. public String Email;
  25. public String Web;
  26.  
  27. public String toString(){
  28. return FirstName+" "+LastName+" "+Company+" "+Address+" "+City+" "+County+"
  29. "+State+" "+Zip+" "+Phone+" "+Phone+" "+Fax+" "+Email+" "+Web;
  30.  
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37. public class JTeagueITCO321IPWeek4 {
  38.  
  39.  
  40.  
  41. /**
  42. * @param args the command line arguments
  43. * @throws java.io.FileNotFoundException
  44. */
  45. public static void main(String[] args) throws FileNotFoundException,
  46. IOException {
  47.  
  48. String line = "";
  49. ArrayList <Employee> ALEmployee = new ArrayList();
  50.  
  51. FileReader fr = new
  52. FileReader("C:\Users\User\Downloads\ITCO321_U4IP_sample_data.csv");
  53. try (BufferedReader br = new BufferedReader(fr)) {
  54. while ((line = br.readLine())!=null){
  55. Employee emp = new Employee();
  56. String[] empFields = line.split(",");
  57. emp.FirstName = empFields[0];
  58. emp.LastName = empFields[1];
  59. emp.Company = empFields[2];
  60. emp.Address = empFields[3];
  61. emp.City = empFields[4];
  62. emp.County = empFields[5];
  63. emp.State = empFields[6];
  64. emp.Zip = empFields[7];
  65. emp.Phone = empFields[8];
  66. emp.Fax = empFields[9];
  67. emp.Email = empFields[10];
  68. emp.Web = empFields[11];
  69. ALEmployee.add(emp);
  70. }
  71. }
  72. ALEmployee.forEach((e) -> {
  73. System.out.println(e);
  74. });
  75.  
  76. }
  77. }
Add Comment
Please, Sign In to add comment