Create a class called DuplicateRemover. Create an instance method called remove that takes a single parameter called dataFile of type String (representing the path to a text file) and uses a Set of Strings to eliminate duplicate words from the file referenced by dataFile. The unique words should be stored in an instance variable called uniqueWords. Create an instance method called write that takes a single parameter called outputFile (representing the path to a text file) and writes the words contained in uniqueWords to the file pointed to by outputFile. The output file should be overwritten if it already exists, and created if it does not exist.
Create a separate class called Application that contains a main method which illustrates the use of DuplicateRemover by calling both the remove and write methods. Your input file must be called problem1.txt and your output file must be called unique_words.txt. Your input file should be located within your project structure so that you can reference it with the relative path of "problem1.txt", and not an absolute path.
You may consider a word to be any sequence of characters separated by whitespace. You do not need to worry about removing punctuation, but you can if you'd like. Additionally, capitalization should not matter when determining the uniqueness of a word.
You must handle any exceptions that will be thrown within the method that throws them. You are forbidden from simply adding a "throws IOException" to your method signatures.
Your program should work on any text file. The TA's will provide their own version of problem1.txt when they run your code.
Create a class called DuplicateCounter. Create an instance method called count that takes a single parameter called dataFile of type String (representing the path to a text file) and uses a Map of Strings to count how many times each word occurs in dataFile. The counts should be stored in an instance variable called wordCounter. Create an instance method called write that takes a single parameter called outputFile (representing the path to a text file) and writes the contents of wordCounter to the file pointed to by outputFile. The output file should be overwritten if it already exists, and created if it does not exist.
Create a separate class called Application that contains a main method which illustrates the use of DuplicateCounter by calling both the remove and write methods. Your input file must be called problem2.txt and your output file must be called unique_word_counts.txt. Your input file should be located within your project structure so that you can reference it with the relative path of "problem2.txt", and not an absolute path.
You may consider a word to be any sequence of characters separated by whitespace. You do not need to worry about removing punctuation, but you can if you'd like. Additionally, capitalization should not matter when determining the uniqueness of a word.
You must handle any exceptions that will be thrown within the method that throws them. You are forbidden from simply adding a "throws IOException" to your method signatures.
Your program should work on any text file. The TA's will provide their own version of problem1.txt when they run your code.