Question: Create a Java program that will create a txt file to read, read the file, create an ArrayList, modify the ArrayList, and write another file.

Create a Java program that will create a txt file to read, read the file, create an ArrayList, modify the ArrayList, and write another file.
Create the txt file in a text editor (maryLambln.txt)
Add the first two lines of the first verse of the children's song "May had a little lamb" to the file
Mary had a little lamb,
Its fleece was white as snow, yeah.
Code the main method
Create an ArrayList called song by calling the readFile method
Add two lines to the ArrayList:
Everywhere the child went,
The little lamb was sure to go, yeah.
Call the writeFile method with song as the argument
Create a method called readFile which returns an ArrayList
Connect to the file.
Save the verses of the file in the ArrayList
Close the file
return the ArrayList
Create a method that writes to a file (maryLambOut.txt). The method is called writeFile with an ArrayList of String as a parameter.
Write the contents of the array to the file
Create a Java program that will create a txt file

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!