Sale!

CST8132 Exercise 8 – File IO

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (3 votes)

Steps:
• Create a new project in Eclipse
• Copy the provided wordlist.txt file into the Project folder
• Write a single Class named “Reverser” that performs the requested tasks:
Tasks:
• Use a java.util.Scanner to load each word in the wordlist.txt file into an ArrayList
o Provide the Scanner a reference to a FileReader
• Report the number of words placed into the ArrayList
• Use the java.util.Collections class to reverse the order of the references in the ArrayList
• Use a java.util.Formatter to write the re-ordered words into a new text file named “reversed.txt”
o Provide the Formatter with a reference to a FileWriter
o Make sure that each word is placed onto a separate line
o Additionally, write code so that Java provides the correct end of line terminator for each line.
 Note: No \n, or \r\n allowed!
• Write code to help ensure your program has no resource leaks.
Grading (1 point each):
• Program opens file with Scanner?
• Program loads words into ArrayList?
• Program reports number of words loaded into ArrayList?
• Collections class was used to reverse order of references to words in the ArrayList?
• Program writes to a new file using Formatter?
• Program uses Java code to insert correct end of line terminator after each word?
• IOException is caught?
• Scanner and Formatter were closed? Formatter was flushed before closed?
• Student shows original file using text editor?
• Student shows new file using text editor?
Reference / Resources:
Note: wordlist was downloaded from the internet and has no warrantees implied or expressed:
John Lawler. (1999). An English Word List. Retrieved from
http://www-personal.umich.edu/~jlawler/wordlist.html
Appendix – Sample Program outputs:
Reading in data
Loaded 69903 words from file
Reversing word list
Writing word list
wordlist.txt:
a
a-horizon
a-ok
aardvark
aardwolf
reversed.txt:
zymurgy
zymotic
zymosis
zymase
zygotic