Question: Part 2 . Read & Write a File ( 3 pts ) In MyFile , implement a public static method called writePrimes that takes two

Part 2. Read & Write a File (3 pts)
In MyFile, implement a public static method called writePrimes that takes two Strings for two
filenames as parameters. The first file contains lines of words or integers (2), separated by commas.
Read the first file, and write any prime numbers to the second file, each on a new line.
Additional requirements
Use try-with-resource.
Use two Scanner objects: one scans the file line by line, the other scans each line word by word.
Has a separate method to check whether a word is a prime. The code should include minimum
number of iterations needed to return a result.
Example
Suppose the filename of the first file is file1, and heres its content:
panda,CS47,2,hello,5,11WOW
yes,no,5,18,3
Then after executing writePrimes("file1", "file2"); a file called file2 will be created and here
will be its content:
2
5
5
3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!