Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 1 MergeFiles: 1. Design a class named MergeFiles I. Three file names are passed as command-line arguments to MergeFiles as follows: java MergeFiles file1

Homework 1 MergeFiles: 1. Design a class named MergeFiles I. Three file names are passed as command-line arguments to MergeFiles as follows: java MergeFiles file1 file2 mergedFile II. MergeFiles reads names stored in files file1 and file2 III. Merges the two list of names into a single list IV. Sorts that single list V. Ignores repetitions VI. Writes the sorted, free-of-repetitions list to a new file named mergedFile.txt VII. The names in all three files are stored as one name per line NOTE: The design of MergeFiles class is very similar to the ReplaceText class that was discussed during the lectures on Exception Handling and File I/O. 2. Create file1.txt and file2.txt in the MergeFiles NetBeans project directory. Put at least five names in each of these files 3. In NetBeans, go to Run > Set Project Configuration > Customize > Arguments. In the field in front of Arguments type the following: file1.txt file2.txt mergedFile.txt 4. Now if you run MergeFiles from within NetBeans, it will run with those three command line arguments 5. Run the program, and examine the resultant mergedFile.txt to ensure that the program is working properly 6. Delete throws Exception from main() and try to run the program. You will receive an error. Is this error due an unchecked exception or checked exception? 7. There is a try block, but no catch or finally blocks in the code. The program, however, still works properly. Why is that?Program Logic f) Create an ArrayList object, names g) Open file1.txt for reading using File and Scanner h) Read the contents of file1.txt into the names object i) Open file2.txt for reading using File and Scanner j) Read the contents of file2.txt and add them to names k) Sort names by first converting it to an array and then applying the built-in Arrays.sort() method l) Print the contents of the sorted array to mergedFile.txt using File and PrintWriter m) Skip any duplicate names while printing n) The MergedFiles class can be invoked as follows: java MergeFiles file1.txt file2.txt mergedFile.txt Challenge Question: Question 1 Read and Save: Create a Java program that reads from a file on the Web using the URL class and save the file content in a local file.

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

Students also viewed these Databases questions

Question

Give three indicators of a multicollinearity problem.

Answered: 1 week ago

Question

How is coaching similar to counseling? How are the two different?

Answered: 1 week ago

Question

Describe the concept of AI in retail.

Answered: 1 week ago