Question: import java.io . BufferedReader; import java.io . FileNotFoundException; import java.io . FileReader; import java.io . IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; public class EV
import java.ioBufferedReader;
import java.ioFileNotFoundException;
import java.ioFileReader;
import java.ioIOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
public class EV
private static final int INITIALCAPACITY ;
private static EVRecord data new EVRecordINITIALCAPACITY;
private static HashSet duplicates new HashSet;
public static void mainString args
Scanner in new ScannerSystemin;
System.out.printlnEnter the file path to read EV data";
String filePath innextLine;
try BufferedReader br new BufferedReadernew FileReaderfilePath
processFilebr;
catch FileNotFoundException e
System.out.printlnFile is not found. Exiting from the program";
System.exit;
catch IOException e
System.out.printlnInput file has some problem. Exiting from the program";
System.exit;
private static void processFileBufferedReader br throws IOException
String line;
int lineCount count duplicateCount invalidCount ;
String header brreadLine;
while line brreadLine null
lineCount;
String columns line.split:$;
if checkColumnLengthcolumnslength
System.out.printlnInvalid data at line lineCount column length does not match.";
continue;
if duplicatescontainscolumns columns
System.out.printlnDuplicate at line lineCount;
duplicateCount;
else
boolean validCheck validateColumnscolumns;
if validCheck
System.out.printlnInvalid data at line lineCount;
invalidCount;
else
EVRecord newRecord new EVRecordcolumns;
if count data.length
data Arrays.copyOfdata data.length ;
datacount newRecord;
count;
duplicates.addnewRecordgetRecordID;
System.out.printlnrecordID; header.replaceAll;;
printReversecount;
System.out.printlnData lines read:" lineCount Records in memory: count Invalid records: invalidCount Duplicate records: duplicateCount;
private static boolean checkColumnLengthint length
return length ;
private static void printReverseint count
for int i count ; i ; i
System.out.printlndatai;
private static boolean validateColumnsString columns
Validation logic for columns
package week;
public class EVRecord
private String attribute;
private int attribute;
Add other attributes as needed
Constructor with parameters
public EVRecordString attribute int attribute
this.attribute attribute;
this.attribute attribute;
Initialize other attributes if needed
Accessor methods
public String getAttribute
return attribute;
public int getAttribute
return attribute;
Mutator methods if needed
public void setAttributeString attribute
this.attribute attribute;
public void setAttributeint attribute
this.attribute attribute;
toString method to print attributes with comma
@Override
public String toString
return attribute attribute;
Add other attributes if needed
fix these code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
