Add instruction to what every step does: public class Main { public static void
ID: 3809726 • Letter: A
Question
Add instruction to what every step does: public class Main { public static void main(String[] args) throws SQLException, FileNotFoundException { DbHelper dbHelper = DbHelper.getInstance(); dbHelper.init(); processDataFile("contacts.txt"); dbHelper.close(); } private static void processDataFile(String fileName) throws FileNotFoundException, SQLException { // start your work here // open and read the file contacts.txt Scanner scn = new Scanner(new File(fileName)); while(scn.hasNextLine()){ String[] data = scn.nextLine().trim().split(","); String name = data[0]; String address = data[1]; String phone = data[2]; Contact contact = new Contact(name,address,phone); contact.save(); } } }
Explanation / Answer
IN Tihs Progrma First Main Method excute which create instance of DbHelper Class.
Then init() method of the specified applet is executed as the first order of business.
Then We Called Method processDataFile with file name.
IN this Method Create Object For Scanner Class, with input of file name.
Then use while loop , which is continue till end of file occure.
We have split the data of each line and store it into String array and then retrive value and store into locat varriable.
Then Create instance of Contact class and pass all local variable value int this.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.