Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Your boss has just put you in charge of updating the company's client contact list. This file contains records in the following format: id,first_name,last_name,email

Java

Your boss has just put you in charge of updating the company's client contact list.

This file contains records in the following format:

id,first_name,last_name,email 1,Norry,Killby,nkillby0@photobucket.com

Your job is to reformat each record as follows:

last_name, first_name, email Killby, Norry 

Starter Code:

package contactlistupdater;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.nio.file.Paths;

import java.util.Formatter;

import java.util.Scanner;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

public class ContactListUpdater {

private static final String INPUT_FILENAME = "contacts.txt";

private static final String OUTPUT_FILENAME = "updated-contacts.txt";

/**

* Transforms a String containing a contact entry to a new format

*/

public static String processContactEntry(String input) {

// TODO your code here...

return input;

}

public static void main(String[] args) {

// Open input/output files and process line by line

try (Formatter output = new Formatter(OUTPUT_FILENAME)) {

try (Scanner input = new Scanner(Paths.get(INPUT_FILENAME))) {

// Process each line

while (input.hasNextLine()) {

output.format("%s%n",

processContactEntry(input.nextLine()));

}

}

catch (IOException ex) {

System.err.println("Unable to open input file: " +

INPUT_FILENAME);

ex.printStackTrace();

}

}

catch (FileNotFoundException ex) {

System.err.println("Unable to open output file: " +

OUTPUT_FILENAME);

ex.printStackTrace();

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

Assess the contributions of small businesses to our economy.

Answered: 1 week ago