java this program reads in from a file called file txt eachline of the file is then 4946384
JAVA: This program reads in from a file called File.txt. Eachline of the file is then stored in an array. But then that arrayneeds to be stored in separate arrays by year. How is thisachieved? I thought I had it but nothing shows up in my 2014 and2015 arrays.
Driver.java package project1; import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class Driver { public static void main(String[] args) throwsFileNotFoundException { String[][] array2014 = new String[10][6]; String[][] array2015 = new String[10][6]; String[] array1 = new String[6]; Driver obj = new Driver(); File myFile = new File(args[0]); Scanner inFile = new Scanner(myFile); String oneLine; int i = 0, k = 0; while (inFile.hasNextLine()) { oneLine = inFile.nextLine(); array1 = oneLine.split(“[, ]”); if(array1[0] == “2014”) { for(int j = 0; j
File.txt 2015 Employee Campbell,Steve 3000
2014 Salesman Sanchez,Carlos 4000 200000
2015 Executive Oduala,Barack 600 . . .